site.conf 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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; includeSubDomains";
  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-Permitted-Cross-Domain-Policies none;
  34. index index.php index.html;
  35. include /etc/nginx/conf.d/listen_plain.active;
  36. include /etc/nginx/conf.d/listen_ssl.active;
  37. include /etc/nginx/conf.d/server_name.active;
  38. error_log /var/log/nginx/error.log;
  39. access_log /var/log/nginx/access.log;
  40. absolute_redirect off;
  41. root /web;
  42. location ~ ^/api/v1/(.*)$ {
  43. try_files $uri $uri/ /json_api.php?query=$1;
  44. }
  45. location ^~ /.well-known/acme-challenge/ {
  46. allow all;
  47. default_type "text/plain";
  48. }
  49. # If behind reverse proxy, forwards the correct IP
  50. set_real_ip_from 10.0.0.0/8;
  51. set_real_ip_from 172.16.0.0/12;
  52. set_real_ip_from 192.168.0.0/16;
  53. set_real_ip_from fc00::/7;
  54. real_ip_header X-Forwarded-For;
  55. real_ip_recursive on;
  56. rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
  57. rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
  58. location ^~ /principals {
  59. return 301 /SOGo/dav;
  60. }
  61. location ~ \.php$ {
  62. try_files $uri =404;
  63. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  64. fastcgi_pass phpfpm:9002;
  65. fastcgi_index index.php;
  66. include /etc/nginx/fastcgi_params;
  67. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  68. fastcgi_param PATH_INFO $fastcgi_path_info;
  69. fastcgi_read_timeout 1200;
  70. }
  71. location /rspamd/ {
  72. proxy_pass http://rspamd:11334/;
  73. proxy_set_header Host $http_host;
  74. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  75. proxy_set_header X-Real-IP $remote_addr;
  76. proxy_redirect off;
  77. expires $expires;
  78. }
  79. location ~* ^/Autodiscover/Autodiscover.xml {
  80. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  81. fastcgi_pass phpfpm:9002;
  82. include /etc/nginx/fastcgi_params;
  83. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  84. try_files /autodiscover.php =404;
  85. }
  86. location ~* ^/Autodiscover/Autodiscover.json {
  87. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  88. fastcgi_pass phpfpm:9002;
  89. include /etc/nginx/fastcgi_params;
  90. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  91. try_files /autodiscover-json.php =404;
  92. }
  93. location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
  94. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  95. fastcgi_pass phpfpm:9002;
  96. include /etc/nginx/fastcgi_params;
  97. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  98. try_files /autoconfig.php =404;
  99. }
  100. location ^~ /Microsoft-Server-ActiveSync {
  101. include /etc/nginx/conf.d/sogo_eas.active;
  102. proxy_connect_timeout 1000;
  103. proxy_next_upstream timeout error;
  104. proxy_send_timeout 1000;
  105. proxy_read_timeout 1000;
  106. proxy_buffer_size 8k;
  107. proxy_buffers 4 32k;
  108. proxy_temp_file_write_size 64k;
  109. proxy_busy_buffers_size 64k;
  110. proxy_set_header X-Real-IP $remote_addr;
  111. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  112. proxy_set_header Host $http_host;
  113. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  114. proxy_set_header x-webobjects-remote-host $remote_addr;
  115. proxy_set_header x-webobjects-server-name $server_name;
  116. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  117. proxy_set_header x-webobjects-server-port $server_port;
  118. client_body_buffer_size 128k;
  119. client_max_body_size 0;
  120. }
  121. location ^~ /SOGo {
  122. include /etc/nginx/conf.d/sogo.active;
  123. proxy_set_header X-Real-IP $remote_addr;
  124. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  125. proxy_set_header Host $http_host;
  126. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  127. proxy_set_header x-webobjects-remote-host $remote_addr;
  128. proxy_set_header x-webobjects-server-name $server_name;
  129. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  130. proxy_set_header x-webobjects-server-port $server_port;
  131. client_body_buffer_size 128k;
  132. client_max_body_size 0;
  133. break;
  134. }
  135. location /SOGo.woa/WebServerResources/ {
  136. proxy_pass http://sogo:9192/WebServerResources/;
  137. proxy_set_header Host $http_host;
  138. proxy_cache sogo;
  139. proxy_cache_valid 200 1d;
  140. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  141. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  142. expires $expires;
  143. allow all;
  144. }
  145. location /.woa/WebServerResources/ {
  146. proxy_pass http://sogo:9192/WebServerResources/;
  147. proxy_set_header Host $http_host;
  148. proxy_cache sogo;
  149. proxy_cache_valid 200 1d;
  150. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  151. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  152. expires $expires;
  153. allow all;
  154. }
  155. location /SOGo/WebServerResources/ {
  156. proxy_pass http://sogo:9192/WebServerResources/;
  157. proxy_set_header Host $http_host;
  158. proxy_cache sogo;
  159. proxy_cache_valid 200 1d;
  160. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  161. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  162. allow all;
  163. }
  164. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) {
  165. proxy_pass http://sogo:9192/$1.SOGo/Resources/$2;
  166. proxy_set_header Host $http_host;
  167. proxy_cache sogo;
  168. proxy_cache_valid 200 1d;
  169. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  170. #alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  171. }
  172. include /etc/nginx/conf.d/site.*.custom;
  173. }