site-defaults.conf 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. include /etc/nginx/mime.types;
  2. charset utf-8;
  3. override_charset on;
  4. server_tokens off;
  5. ssl_protocols TLSv1.2 TLSv1.3;
  6. ssl_prefer_server_ciphers on;
  7. ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
  8. ssl_ecdh_curve X25519:X448:secp384r1:secp256k1;
  9. ssl_session_cache shared:SSL:50m;
  10. ssl_session_timeout 1d;
  11. ssl_session_tickets off;
  12. add_header Strict-Transport-Security "max-age=15768000;";
  13. add_header X-Content-Type-Options nosniff;
  14. add_header X-XSS-Protection "1; mode=block";
  15. add_header X-Robots-Tag none;
  16. add_header X-Download-Options noopen;
  17. add_header X-Frame-Options "SAMEORIGIN" always;
  18. add_header X-Permitted-Cross-Domain-Policies none;
  19. add_header Referrer-Policy strict-origin;
  20. index index.php index.html;
  21. client_max_body_size 0;
  22. gzip on;
  23. gzip_disable "msie6";
  24. gzip_vary on;
  25. gzip_proxied off;
  26. gzip_comp_level 6;
  27. gzip_buffers 16 8k;
  28. gzip_http_version 1.1;
  29. gzip_min_length 256;
  30. 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;
  31. location ~ ^/(fonts|js|css|img)/ {
  32. expires max;
  33. add_header Cache-Control public;
  34. }
  35. error_log /var/log/nginx/error.log;
  36. access_log /var/log/nginx/access.log;
  37. fastcgi_hide_header X-Powered-By;
  38. absolute_redirect off;
  39. root /web;
  40. location / {
  41. try_files $uri $uri/ @strip-ext;
  42. }
  43. location /qhandler {
  44. rewrite ^/qhandler/(.*)/(.*) /qhandler.php?action=$1&hash=$2;
  45. }
  46. location /edit {
  47. rewrite ^/edit/(.*)/(.*) /edit.php?$1=$2;
  48. }
  49. location @strip-ext {
  50. rewrite ^(.*)$ $1.php last;
  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 3600;
  80. fastcgi_send_timeout 3600;
  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. 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/includes/sogo_proxy_auth.conf;
  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. location ~* ^/SOGo/so/.*\.(xml|js|html|xhtml)$ {
  144. include /etc/nginx/conf.d/includes/sogo_proxy_auth.conf;
  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_hide_header Content-Type;
  155. add_header Content-Type text/plain;
  156. break;
  157. }
  158. include /etc/nginx/conf.d/includes/sogo_proxy_auth.conf;
  159. include /etc/nginx/conf.d/sogo.active;
  160. proxy_set_header X-Real-IP $remote_addr;
  161. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  162. proxy_set_header Host $http_host;
  163. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  164. proxy_set_header x-webobjects-remote-host $remote_addr;
  165. proxy_set_header x-webobjects-server-name $server_name;
  166. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  167. proxy_set_header x-webobjects-server-port $server_port;
  168. proxy_send_timeout 3600;
  169. proxy_read_timeout 3600;
  170. client_body_buffer_size 128k;
  171. client_max_body_size 0;
  172. break;
  173. }
  174. location ~* /sogo$ {
  175. return 301 $client_req_scheme://$http_host/SOGo;
  176. }
  177. location /SOGo.woa/WebServerResources/ {
  178. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  179. }
  180. location /.woa/WebServerResources/ {
  181. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  182. }
  183. location /SOGo/WebServerResources/ {
  184. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  185. }
  186. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) {
  187. alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  188. }
  189. include /etc/nginx/conf.d/site.*.custom;
  190. error_page 502 @awaitingupstream;
  191. location @awaitingupstream {
  192. rewrite ^(.*)$ /_status.502.html break;
  193. }
  194. location ~ ^/cache/(.*)$ {
  195. try_files $uri $uri/ /resource.php?file=$1;
  196. }