site-defaults.conf 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. include /etc/nginx/mime.types;
  2. charset utf-8;
  3. override_charset on;
  4. ssl_protocols TLSv1.2 TLSv1.3;
  5. 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';
  6. ssl_prefer_server_ciphers on;
  7. ssl_session_cache shared:SSL:50m;
  8. ssl_session_timeout 1d;
  9. ssl_session_tickets off;
  10. add_header Strict-Transport-Security "max-age=15768000;";
  11. add_header X-Content-Type-Options nosniff;
  12. add_header X-XSS-Protection "1; mode=block";
  13. add_header X-Robots-Tag none;
  14. add_header X-Download-Options noopen;
  15. add_header X-Frame-Options "SAMEORIGIN" always;
  16. add_header X-Permitted-Cross-Domain-Policies none;
  17. add_header Referrer-Policy strict-origin;
  18. index index.php index.html;
  19. client_max_body_size 0;
  20. gzip on;
  21. gzip_disable "msie6";
  22. gzip_vary on;
  23. gzip_proxied off;
  24. gzip_comp_level 6;
  25. gzip_buffers 16 8k;
  26. gzip_http_version 1.1;
  27. gzip_min_length 256;
  28. gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
  29. location ~ ^/(fonts|js|css|img)/ {
  30. expires max;
  31. add_header Cache-Control public;
  32. }
  33. error_log /var/log/nginx/error.log;
  34. access_log /var/log/nginx/access.log;
  35. absolute_redirect off;
  36. root /web;
  37. location / {
  38. try_files $uri $uri/ @strip-ext;
  39. }
  40. location /qhandler {
  41. rewrite ^/qhandler/(.*)/(.*) /qhandler.php?action=$1&hash=$2;
  42. }
  43. location /edit {
  44. rewrite ^/edit/(.*)/(.*) /edit.php?$1=$2;
  45. }
  46. location @strip-ext {
  47. rewrite ^(.*)$ $1.php last;
  48. }
  49. location /api {
  50. try_files /_apidocs.html =404;
  51. }
  52. location ~ ^/api/v1/(.*)$ {
  53. try_files $uri $uri/ /json_api.php?query=$1;
  54. }
  55. location ^~ /.well-known/acme-challenge/ {
  56. allow all;
  57. default_type "text/plain";
  58. }
  59. # If behind reverse proxy, forwards the correct IP
  60. set_real_ip_from 10.0.0.0/8;
  61. set_real_ip_from 172.16.0.0/12;
  62. set_real_ip_from 192.168.0.0/16;
  63. set_real_ip_from fc00::/7;
  64. real_ip_header X-Forwarded-For;
  65. real_ip_recursive on;
  66. rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
  67. rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
  68. location ^~ /principals {
  69. return 301 /SOGo/dav;
  70. }
  71. location ~ \.php$ {
  72. try_files $uri =404;
  73. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  74. fastcgi_pass phpfpm:9002;
  75. fastcgi_index index.php;
  76. include /etc/nginx/fastcgi_params;
  77. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  78. fastcgi_param PATH_INFO $fastcgi_path_info;
  79. fastcgi_read_timeout 1200;
  80. }
  81. location /rspamd/ {
  82. location /rspamd/auth {
  83. # proxy_pass is not inherited
  84. proxy_pass http://rspamd:11334/auth;
  85. proxy_intercept_errors on;
  86. proxy_set_header Host $http_host;
  87. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  88. proxy_set_header X-Real-IP $remote_addr;
  89. proxy_redirect off;
  90. error_page 403 /_rspamderror.php;
  91. }
  92. proxy_pass http://rspamd:11334/;
  93. proxy_set_header Host $http_host;
  94. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  95. proxy_set_header X-Real-IP $remote_addr;
  96. proxy_redirect off;
  97. }
  98. location ~* ^/Autodiscover/Autodiscover.xml {
  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.php =404;
  104. }
  105. location ~* ^/Autodiscover/Autodiscover.json {
  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 /autodiscover-json.php =404;
  111. }
  112. location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
  113. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  114. fastcgi_pass phpfpm:9002;
  115. include /etc/nginx/fastcgi_params;
  116. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  117. try_files /autoconfig.php =404;
  118. }
  119. # auth_request endpoint if ALLOW_ADMIN_EMAIL_LOGIN is set
  120. location /sogo-auth-verify {
  121. internal;
  122. proxy_set_header X-Original-URI $request_uri;
  123. proxy_set_header X-Real-IP $remote_addr;
  124. proxy_set_header Host $http_host;
  125. proxy_set_header Content-Length "";
  126. proxy_pass http://127.0.0.1:65510/sogo-auth;
  127. proxy_pass_request_body off;
  128. }
  129. location ^~ /Microsoft-Server-ActiveSync {
  130. include /etc/nginx/conf.d/sogo_proxy_auth.active;
  131. include /etc/nginx/conf.d/sogo_eas.active;
  132. proxy_connect_timeout 75;
  133. proxy_send_timeout 3600;
  134. proxy_read_timeout 3600;
  135. proxy_buffers 64 256k;
  136. proxy_set_header X-Real-IP $remote_addr;
  137. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  138. proxy_set_header Host $http_host;
  139. client_body_buffer_size 512k;
  140. client_max_body_size 0;
  141. }
  142. location ^~ /SOGo {
  143. include /etc/nginx/conf.d/sogo_proxy_auth.active;
  144. include /etc/nginx/conf.d/sogo.active;
  145. proxy_set_header X-Real-IP $remote_addr;
  146. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  147. proxy_set_header Host $http_host;
  148. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  149. proxy_set_header x-webobjects-remote-host $remote_addr;
  150. proxy_set_header x-webobjects-server-name $server_name;
  151. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  152. proxy_set_header x-webobjects-server-port $server_port;
  153. proxy_send_timeout 300;
  154. proxy_read_timeout 300;
  155. client_body_buffer_size 128k;
  156. client_max_body_size 0;
  157. break;
  158. }
  159. location ~* /sogo$ {
  160. return 301 $client_req_scheme://$http_host/SOGo;
  161. }
  162. location /SOGo.woa/WebServerResources/ {
  163. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  164. }
  165. location /.woa/WebServerResources/ {
  166. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  167. }
  168. location /SOGo/WebServerResources/ {
  169. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  170. }
  171. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) {
  172. alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  173. }
  174. include /etc/nginx/conf.d/site.*.custom;
  175. error_page 502 @awaitingupstream;
  176. location @awaitingupstream {
  177. rewrite ^(.*)$ /_status.502.html break;
  178. }
  179. location ~ ^/cache/(.*)$ {
  180. try_files $uri $uri/ /resource.php?file=$1;
  181. }