site.conf 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. server_tokens off;
  2. proxy_cache_path /tmp levels=1:2 keys_zone=sogo:10m inactive=24h max_size=1g;
  3. server_names_hash_bucket_size 64;
  4. map $http_x_forwarded_proto $client_req_scheme {
  5. default $scheme;
  6. https https;
  7. }
  8. map $sent_http_content_type $expires {
  9. default off;
  10. text/html off;
  11. text/css 1d;
  12. application/javascript 1d;
  13. application/json off;
  14. image/png 1d;
  15. }
  16. server {
  17. include /etc/nginx/mime.types;
  18. charset utf-8;
  19. override_charset on;
  20. ssl_certificate /etc/ssl/mail/cert.pem;
  21. ssl_certificate_key /etc/ssl/mail/key.pem;
  22. ssl_protocols TLSv1.2;
  23. 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';
  24. ssl_prefer_server_ciphers on;
  25. ssl_session_cache shared:SSL:50m;
  26. ssl_session_timeout 1d;
  27. ssl_session_tickets off;
  28. add_header Strict-Transport-Security "max-age=15768000;";
  29. add_header X-Content-Type-Options nosniff;
  30. add_header X-XSS-Protection "1; mode=block";
  31. add_header X-Robots-Tag none;
  32. add_header X-Download-Options noopen;
  33. add_header X-Frame-Options "SAMEORIGIN" always;
  34. add_header X-Permitted-Cross-Domain-Policies none;
  35. add_header Referrer-Policy strict-origin;
  36. index index.php index.html;
  37. client_max_body_size 0;
  38. include /etc/nginx/conf.d/listen_plain.active;
  39. include /etc/nginx/conf.d/listen_ssl.active;
  40. include /etc/nginx/conf.d/server_name.active;
  41. error_log /var/log/nginx/error.log;
  42. access_log /var/log/nginx/access.log;
  43. absolute_redirect off;
  44. root /web;
  45. location / {
  46. try_files $uri $uri/ @strip-ext;
  47. }
  48. location /edit {
  49. rewrite ^/edit/(.*)/(.*) /edit.php?$1=$2;
  50. }
  51. location @strip-ext {
  52. rewrite ^(.*)$ $1.php last;
  53. }
  54. location ~ ^/api/v1/(.*)$ {
  55. try_files $uri $uri/ /json_api.php?query=$1;
  56. }
  57. location ^~ /.well-known/acme-challenge/ {
  58. allow all;
  59. default_type "text/plain";
  60. }
  61. # If behind reverse proxy, forwards the correct IP
  62. set_real_ip_from 10.0.0.0/8;
  63. set_real_ip_from 172.16.0.0/12;
  64. set_real_ip_from 192.168.0.0/16;
  65. set_real_ip_from fc00::/7;
  66. real_ip_header X-Forwarded-For;
  67. real_ip_recursive on;
  68. rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
  69. rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
  70. location ^~ /principals {
  71. return 301 /SOGo/dav;
  72. }
  73. location ~ \.php$ {
  74. try_files $uri =404;
  75. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  76. fastcgi_pass phpfpm:9002;
  77. fastcgi_index index.php;
  78. include /etc/nginx/fastcgi_params;
  79. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  80. fastcgi_param PATH_INFO $fastcgi_path_info;
  81. fastcgi_read_timeout 1200;
  82. }
  83. location /rspamd/ {
  84. proxy_pass http://rspamd:11334/;
  85. proxy_set_header Host $http_host;
  86. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  87. proxy_set_header X-Real-IP $remote_addr;
  88. proxy_redirect off;
  89. expires $expires;
  90. }
  91. location ~* ^/Autodiscover/Autodiscover.xml {
  92. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  93. fastcgi_pass phpfpm:9002;
  94. include /etc/nginx/fastcgi_params;
  95. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  96. try_files /autodiscover.php =404;
  97. }
  98. location ~* ^/Autodiscover/Autodiscover.json {
  99. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  100. fastcgi_pass phpfpm:9002;
  101. include /etc/nginx/fastcgi_params;
  102. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  103. try_files /autodiscover-json.php =404;
  104. }
  105. location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
  106. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  107. fastcgi_pass phpfpm:9002;
  108. include /etc/nginx/fastcgi_params;
  109. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  110. try_files /autoconfig.php =404;
  111. }
  112. location ^~ /Microsoft-Server-ActiveSync {
  113. include /etc/nginx/conf.d/sogo_eas.active;
  114. proxy_connect_timeout 4000;
  115. proxy_next_upstream timeout error;
  116. proxy_send_timeout 4000;
  117. proxy_read_timeout 4000;
  118. proxy_buffer_size 8k;
  119. proxy_buffers 16 64k;
  120. proxy_temp_file_write_size 64k;
  121. proxy_busy_buffers_size 64k;
  122. proxy_set_header X-Real-IP $remote_addr;
  123. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  124. proxy_set_header Host $http_host;
  125. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  126. proxy_set_header x-webobjects-remote-host $remote_addr;
  127. proxy_set_header x-webobjects-server-name $server_name;
  128. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  129. proxy_set_header x-webobjects-server-port $server_port;
  130. client_body_buffer_size 128k;
  131. client_max_body_size 0;
  132. }
  133. location ^~ /SOGo {
  134. include /etc/nginx/conf.d/sogo.active;
  135. proxy_set_header X-Real-IP $remote_addr;
  136. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  137. proxy_set_header Host $http_host;
  138. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  139. proxy_set_header x-webobjects-remote-host $remote_addr;
  140. proxy_set_header x-webobjects-server-name $server_name;
  141. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  142. proxy_set_header x-webobjects-server-port $server_port;
  143. client_body_buffer_size 128k;
  144. client_max_body_size 0;
  145. break;
  146. }
  147. location /SOGo.woa/WebServerResources/ {
  148. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  149. }
  150. location /.woa/WebServerResources/ {
  151. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  152. }
  153. location /SOGo/WebServerResources/ {
  154. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  155. }
  156. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) {
  157. alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  158. }
  159. include /etc/nginx/conf.d/site.*.custom;
  160. }