site-defaults.conf 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. fastcgi_hide_header X-Powered-By;
  36. absolute_redirect off;
  37. root /web;
  38. location / {
  39. try_files $uri $uri/ @strip-ext;
  40. }
  41. location /qhandler {
  42. rewrite ^/qhandler/(.*)/(.*) /qhandler.php?action=$1&hash=$2;
  43. }
  44. location /edit {
  45. rewrite ^/edit/(.*)/(.*) /edit.php?$1=$2;
  46. }
  47. location @strip-ext {
  48. rewrite ^(.*)$ $1.php last;
  49. }
  50. location /api {
  51. try_files /_apidocs.html =404;
  52. }
  53. location ~ ^/api/v1/(.*)$ {
  54. try_files $uri $uri/ /json_api.php?query=$1;
  55. }
  56. location ^~ /.well-known/acme-challenge/ {
  57. allow all;
  58. default_type "text/plain";
  59. }
  60. # If behind reverse proxy, forwards the correct IP
  61. set_real_ip_from 10.0.0.0/8;
  62. set_real_ip_from 172.16.0.0/12;
  63. set_real_ip_from 192.168.0.0/16;
  64. set_real_ip_from fc00::/7;
  65. real_ip_header X-Forwarded-For;
  66. real_ip_recursive on;
  67. rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
  68. rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
  69. location ^~ /principals {
  70. return 301 /SOGo/dav;
  71. }
  72. location ~ \.php$ {
  73. try_files $uri =404;
  74. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  75. fastcgi_pass phpfpm:9002;
  76. fastcgi_index index.php;
  77. include /etc/nginx/fastcgi_params;
  78. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  79. fastcgi_param PATH_INFO $fastcgi_path_info;
  80. fastcgi_read_timeout 1200;
  81. }
  82. location /rspamd/ {
  83. location /rspamd/auth {
  84. # proxy_pass is not inherited
  85. proxy_pass http://rspamd:11334/auth;
  86. proxy_intercept_errors on;
  87. proxy_set_header Host $http_host;
  88. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  89. proxy_set_header X-Real-IP $remote_addr;
  90. proxy_redirect off;
  91. error_page 403 /_rspamderror.php;
  92. }
  93. proxy_pass http://rspamd:11334/;
  94. proxy_set_header Host $http_host;
  95. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  96. proxy_set_header X-Real-IP $remote_addr;
  97. proxy_redirect off;
  98. }
  99. location ~* ^/Autodiscover/Autodiscover.xml {
  100. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  101. fastcgi_pass phpfpm:9002;
  102. include /etc/nginx/fastcgi_params;
  103. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  104. try_files /autodiscover.php =404;
  105. }
  106. location ~* ^/Autodiscover/Autodiscover.json {
  107. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  108. fastcgi_pass phpfpm:9002;
  109. include /etc/nginx/fastcgi_params;
  110. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  111. try_files /autodiscover-json.php =404;
  112. }
  113. location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
  114. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  115. fastcgi_pass phpfpm:9002;
  116. include /etc/nginx/fastcgi_params;
  117. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  118. try_files /autoconfig.php =404;
  119. }
  120. # auth_request endpoint if ALLOW_ADMIN_EMAIL_LOGIN is set
  121. location /sogo-auth-verify {
  122. internal;
  123. proxy_set_header X-Original-URI $request_uri;
  124. proxy_set_header X-Real-IP $remote_addr;
  125. proxy_set_header Host $http_host;
  126. proxy_set_header Content-Length "";
  127. proxy_pass http://127.0.0.1:65510/sogo-auth;
  128. proxy_pass_request_body off;
  129. }
  130. location ^~ /Microsoft-Server-ActiveSync {
  131. include /etc/nginx/conf.d/sogo_proxy_auth.active;
  132. include /etc/nginx/conf.d/sogo_eas.active;
  133. proxy_connect_timeout 75;
  134. proxy_send_timeout 3600;
  135. proxy_read_timeout 3600;
  136. proxy_buffers 64 256k;
  137. proxy_set_header X-Real-IP $remote_addr;
  138. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  139. proxy_set_header Host $http_host;
  140. client_body_buffer_size 512k;
  141. client_max_body_size 0;
  142. }
  143. location ^~ /SOGo {
  144. include /etc/nginx/conf.d/sogo_proxy_auth.active;
  145. include /etc/nginx/conf.d/sogo.active;
  146. proxy_set_header X-Real-IP $remote_addr;
  147. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  148. proxy_set_header Host $http_host;
  149. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  150. proxy_set_header x-webobjects-remote-host $remote_addr;
  151. proxy_set_header x-webobjects-server-name $server_name;
  152. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  153. proxy_set_header x-webobjects-server-port $server_port;
  154. proxy_send_timeout 300;
  155. proxy_read_timeout 300;
  156. client_body_buffer_size 128k;
  157. client_max_body_size 0;
  158. break;
  159. }
  160. location ~* /sogo$ {
  161. return 301 $client_req_scheme://$http_host/SOGo;
  162. }
  163. location /SOGo.woa/WebServerResources/ {
  164. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  165. }
  166. location /.woa/WebServerResources/ {
  167. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  168. }
  169. location /SOGo/WebServerResources/ {
  170. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  171. }
  172. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) {
  173. alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  174. }
  175. include /etc/nginx/conf.d/site.*.custom;
  176. error_page 502 @awaitingupstream;
  177. location @awaitingupstream {
  178. rewrite ^(.*)$ /_status.502.html break;
  179. }
  180. location ~ ^/cache/(.*)$ {
  181. try_files $uri $uri/ /resource.php?file=$1;
  182. }