site-defaults.conf 6.5 KB

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