|
| 1 | +## Version 2025/03/16 |
| 2 | +# make sure that your mailcow container is named mailcow |
| 3 | +# make sure that you are aqquainted with the mailcow documentation (https://docs.mailcow.email/) |
| 4 | +# make sure you have read the most important entries in the "Get Started" section, "Post Installation Tasks -> Reverse Proxy -> Overview" and "Post Installation Tasks -> Reverse Proxy -> Nginx" sections |
| 5 | +# make sure that your dns is configured as per your domain requirements and the mailcow documentation |
| 6 | +# make sure to set up a mechanism to copy your SSL certificate after each renewal to /data/assets/ssl/ directory for mailcow to use (see mailcow documentation in "Post Installation Tasks -> Reverse Proxy -> Overview") |
| 7 | + |
| 8 | +server { |
| 9 | + listen 443 ssl; |
| 10 | + listen [::]:443 ssl; |
| 11 | + |
| 12 | + server_name mailcow.* autoconfig.* autodiscover.*; # modify these names to match your domain/mailcow configuration |
| 13 | + |
| 14 | + include /config/nginx/ssl.conf; |
| 15 | + |
| 16 | + client_max_body_size 0; |
| 17 | + |
| 18 | + # enable for ldap auth (requires ldap-location.conf in the location block) |
| 19 | + #include /config/nginx/ldap-server.conf; |
| 20 | + |
| 21 | + # enable for Authelia (requires authelia-location.conf in the location block) |
| 22 | + #include /config/nginx/authelia-server.conf; |
| 23 | + |
| 24 | + # enable for Authentik (requires authentik-location.conf in the location block) |
| 25 | + #include /config/nginx/authentik-server.conf; |
| 26 | + |
| 27 | + location / { |
| 28 | + # enable the next two lines for http auth |
| 29 | + #auth_basic "Restricted"; |
| 30 | + #auth_basic_user_file /config/nginx/.htpasswd; |
| 31 | + |
| 32 | + # enable for ldap auth (requires ldap-server.conf in the server block) |
| 33 | + #include /config/nginx/ldap-location.conf; |
| 34 | + |
| 35 | + # enable for Authelia (requires authelia-server.conf in the server block) |
| 36 | + #include /config/nginx/authelia-location.conf; |
| 37 | + |
| 38 | + # enable for Authentik (requires authentik-server.conf in the server block) |
| 39 | + #include /config/nginx/authentik-location.conf; |
| 40 | + |
| 41 | + include /config/nginx/resolver.conf; |
| 42 | + set $upstream_app mailcow; |
| 43 | + set $upstream_port 8080; |
| 44 | + set $upstream_proto http; |
| 45 | + proxy_pass $upstream_proto://$upstream_app:$upstream_port; |
| 46 | + |
| 47 | + proxy_set_header Host $http_host; |
| 48 | + proxy_set_header X-Real-IP $remote_addr; |
| 49 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 50 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 51 | + proxy_buffer_size 128k; |
| 52 | + proxy_buffers 64 512k; |
| 53 | + proxy_busy_buffers_size 512k; |
| 54 | + } |
| 55 | + |
| 56 | + location /Microsoft-Server-ActiveSync { |
| 57 | + include /config/nginx/resolver.conf; |
| 58 | + set $upstream_app mailcow; |
| 59 | + set $upstream_port 8080; |
| 60 | + set $upstream_proto http; |
| 61 | + proxy_pass $upstream_proto://$upstream_app:$upstream_port; |
| 62 | + |
| 63 | + proxy_set_header Host $http_host; |
| 64 | + proxy_set_header X-Real-IP $remote_addr; |
| 65 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 66 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 67 | + proxy_connect_timeout 75; |
| 68 | + proxy_send_timeout 3650; |
| 69 | + proxy_read_timeout 3650; |
| 70 | + proxy_buffers 64 512k; |
| 71 | + |
| 72 | + client_body_buffer_size 512k; |
| 73 | + } |
| 74 | +} |
0 commit comments