mailcow/data/conf/nginx/site.conf

375 lines
12 KiB
Plaintext
Raw Normal View History

server_tokens off;
proxy_cache_path /tmp levels=1:2 keys_zone=sogo:10m inactive=24h max_size=1g;
server_names_hash_bucket_size 64;
2017-05-04 04:26:10 +08:00
map $http_x_forwarded_proto $client_req_scheme {
default $scheme;
https https;
}
geo $non_internal {
default 1;
10.0.0.0/8 0;
172.16.0.0/12 0;
192.168.0.0/16 0;
fc00::/7 0;
2018-01-21 21:59:45 +08:00
}
2017-10-12 14:37:48 +08:00
server {
include /etc/nginx/mime.types;
charset utf-8;
override_charset on;
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Frame-Options "SAMEORIGIN";
2017-10-12 14:37:48 +08:00
add_header X-Permitted-Cross-Domain-Policies none;
index index.php index.html;
include /etc/nginx/conf.d/listen_plain.active;
include /etc/nginx/conf.d/server_name.active;
if ($non_internal) {
return 302 https://$server_name$request_uri;
}
2017-10-12 14:37:48 +08:00
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
absolute_redirect off;
root /web;
location ~ ^/api/v1/(.*)$ {
try_files $uri $uri/ /json_api.php?query=$1;
}
location ^~ /.well-known/acme-challenge/ {
allow all;
default_type "text/plain";
}
# If behind reverse proxy, forwards the correct IP
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
set_real_ip_from fc00::/7;
2017-10-12 14:37:48 +08:00
real_ip_header X-Forwarded-For;
real_ip_recursive on;
rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
location ^~ /principals {
return 301 /SOGo/dav;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PHP_VALUE "max_execution_time = 1200
max_input_time = 1200
memory_limit = 64M";
fastcgi_read_timeout 1200;
}
location /rspamd/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://rspamd:11334/;
2017-10-12 14:37:48 +08:00
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
}
location ~* ^/Autodiscover/Autodiscover.xml {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files /autodiscover.php =404;
}
location ~* ^/Autodiscover/Autodiscover.json {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files /autodiscover-json.php =404;
}
location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files /autoconfig.php =404;
}
location ^~ /Microsoft-Server-ActiveSync {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:20000/SOGo/Microsoft-Server-ActiveSync;
2017-10-12 14:37:48 +08:00
proxy_connect_timeout 1000;
proxy_next_upstream timeout error;
proxy_send_timeout 1000;
proxy_read_timeout 1000;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_temp_file_write_size 64k;
proxy_busy_buffers_size 64k;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
proxy_set_header x-webobjects-remote-host $remote_addr;
proxy_set_header x-webobjects-server-name $server_name;
proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
proxy_set_header x-webobjects-server-port $server_port;
client_body_buffer_size 128k;
client_max_body_size 0;
}
location ^~ /SOGo {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:20000;
2017-10-12 14:37:48 +08:00
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
proxy_set_header x-webobjects-remote-host $remote_addr;
proxy_set_header x-webobjects-server-name $server_name;
proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
proxy_set_header x-webobjects-server-port $server_port;
client_body_buffer_size 128k;
client_max_body_size 0;
break;
}
location /SOGo.woa/WebServerResources/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/WebServerResources/;
2017-10-12 14:37:48 +08:00
proxy_set_header Host $http_host;
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/WebServerResources/;
allow all;
}
location /.woa/WebServerResources/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/WebServerResources/;
2017-10-12 14:37:48 +08:00
proxy_set_header Host $http_host;
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/WebServerResources/;
allow all;
}
location /SOGo/WebServerResources/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/WebServerResources/;
2017-10-12 14:37:48 +08:00
proxy_set_header Host $http_host;
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/WebServerResources/;
allow all;
}
location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/$1.SOGo/Resources/$2;
2017-10-12 14:37:48 +08:00
proxy_set_header Host $http_host;
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
}
include /etc/nginx/conf.d/site.*.custom;
}
2016-12-10 03:39:02 +08:00
server {
include /etc/nginx/mime.types;
2017-01-26 02:04:01 +08:00
charset utf-8;
override_charset on;
2017-09-14 19:34:07 +08:00
2016-12-22 19:20:26 +08:00
ssl on;
ssl_certificate /etc/ssl/mail/cert.pem;
ssl_certificate_key /etc/ssl/mail/key.pem;
2017-09-14 19:34:07 +08:00
ssl_protocols TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
2016-12-22 19:20:26 +08:00
ssl_prefer_server_ciphers on;
2017-09-14 19:34:07 +08:00
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets off;
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Permitted-Cross-Domain-Policies none;
2017-09-11 23:37:25 +08:00
2016-12-22 19:20:26 +08:00
index index.php index.html;
2016-12-10 03:39:02 +08:00
include /etc/nginx/conf.d/listen_ssl.active;
2017-02-28 17:12:18 +08:00
include /etc/nginx/conf.d/server_name.active;
2017-02-28 17:02:02 +08:00
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
absolute_redirect off;
2017-02-28 17:02:02 +08:00
root /web;
2017-04-29 22:36:41 +08:00
location ~ ^/api/v1/(.*)$ {
try_files $uri $uri/ /json_api.php?query=$1;
2017-03-28 17:51:31 +08:00
}
location ^~ /.well-known/acme-challenge/ {
2017-06-15 05:10:50 +08:00
allow all;
default_type "text/plain";
}
2017-02-28 17:02:02 +08:00
# If behind reverse proxy, forwards the correct IP
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
set_real_ip_from fc00::/7;
2017-02-28 17:02:02 +08:00
real_ip_header X-Forwarded-For;
real_ip_recursive on;
2017-06-15 05:14:41 +08:00
rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
2017-06-15 05:17:31 +08:00
rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
2017-06-15 05:14:41 +08:00
2017-06-15 05:10:50 +08:00
location ^~ /principals {
return 301 /SOGo/dav;
2017-02-28 17:02:02 +08:00
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PHP_VALUE "max_execution_time = 1200
max_input_time = 1200
memory_limit = 64M";
fastcgi_read_timeout 1200;
}
location /rspamd/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://rspamd:11334/;
proxy_set_header Host $http_host;
2017-02-28 17:02:02 +08:00
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
2017-02-28 17:02:02 +08:00
}
2017-06-16 05:03:10 +08:00
location ~* ^/Autodiscover/Autodiscover.xml {
2017-05-04 04:26:10 +08:00
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files /autodiscover.php =404;
2017-02-28 17:02:02 +08:00
}
location ~* ^/Autodiscover/Autodiscover.json {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files /autodiscover-json.php =404;
}
location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
2017-05-04 04:26:10 +08:00
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files /autoconfig.php =404;
2017-02-28 17:02:02 +08:00
}
location ^~ /Microsoft-Server-ActiveSync {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:20000/SOGo/Microsoft-Server-ActiveSync;
2017-02-28 17:02:02 +08:00
proxy_connect_timeout 1000;
proxy_next_upstream timeout error;
proxy_send_timeout 1000;
proxy_read_timeout 1000;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_temp_file_write_size 64k;
proxy_busy_buffers_size 64k;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
2017-02-28 17:02:02 +08:00
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
proxy_set_header x-webobjects-remote-host $remote_addr;
proxy_set_header x-webobjects-server-name $server_name;
2017-05-04 04:26:10 +08:00
proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
2017-04-25 16:49:38 +08:00
proxy_set_header x-webobjects-server-port $server_port;
2017-02-28 17:02:02 +08:00
client_body_buffer_size 128k;
2017-08-09 16:17:27 +08:00
client_max_body_size 0;
2017-02-28 17:02:02 +08:00
}
location ^~ /SOGo {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:20000;
2017-02-28 17:02:02 +08:00
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
2017-02-28 17:02:02 +08:00
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
proxy_set_header x-webobjects-remote-host $remote_addr;
proxy_set_header x-webobjects-server-name $server_name;
2017-05-04 04:26:10 +08:00
proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
2017-04-25 16:49:38 +08:00
proxy_set_header x-webobjects-server-port $server_port;
2017-02-28 17:02:02 +08:00
client_body_buffer_size 128k;
2017-08-09 16:17:27 +08:00
client_max_body_size 0;
2017-02-28 17:02:02 +08:00
break;
}
location /SOGo.woa/WebServerResources/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/WebServerResources/;
proxy_set_header Host $http_host;
2017-02-28 17:02:02 +08:00
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/WebServerResources/;
allow all;
}
location /.woa/WebServerResources/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/WebServerResources/;
proxy_set_header Host $http_host;
2017-02-28 17:02:02 +08:00
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/WebServerResources/;
allow all;
}
location /SOGo/WebServerResources/ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/WebServerResources/;
proxy_set_header Host $http_host;
2017-02-28 17:02:02 +08:00
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/WebServerResources/;
allow all;
}
location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$ {
2018-01-21 21:59:45 +08:00
proxy_pass http://sogo:9192/$1.SOGo/Resources/$2;
proxy_set_header Host $http_host;
2017-02-28 17:02:02 +08:00
proxy_cache sogo;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
}
include /etc/nginx/conf.d/site.*.custom;
2017-04-27 05:37:55 +08:00
}