site-defaults.conf 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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&$args;
  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 ^~ /inc/lib/ {
  72. deny all;
  73. return 403;
  74. }
  75. location ~ \.php$ {
  76. try_files $uri =404;
  77. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  78. fastcgi_pass phpfpm:9002;
  79. fastcgi_index index.php;
  80. include /etc/nginx/fastcgi_params;
  81. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  82. fastcgi_param PATH_INFO $fastcgi_path_info;
  83. fastcgi_read_timeout 3600;
  84. fastcgi_send_timeout 3600;
  85. }
  86. location /rspamd/ {
  87. location /rspamd/auth {
  88. # proxy_pass is not inherited
  89. proxy_pass http://rspamd:11334/auth;
  90. proxy_intercept_errors on;
  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. error_page 401 /_rspamderror.php;
  96. }
  97. proxy_pass http://rspamd:11334/;
  98. proxy_set_header Host $http_host;
  99. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  100. proxy_set_header X-Real-IP $remote_addr;
  101. proxy_redirect off;
  102. }
  103. location ~* ^/Autodiscover/Autodiscover.xml {
  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.php =404;
  109. }
  110. location ~* ^/Autodiscover/Autodiscover.json {
  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 /autodiscover-json.php =404;
  116. }
  117. location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
  118. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  119. fastcgi_pass phpfpm:9002;
  120. include /etc/nginx/fastcgi_params;
  121. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  122. try_files /autoconfig.php =404;
  123. }
  124. location /sogo-auth-verify {
  125. internal;
  126. proxy_set_header X-Original-URI $request_uri;
  127. proxy_set_header X-Real-IP $remote_addr;
  128. proxy_set_header Host $http_host;
  129. proxy_set_header Content-Length "";
  130. proxy_pass http://127.0.0.1:65510/sogo-auth;
  131. proxy_pass_request_body off;
  132. }
  133. location ^~ /Microsoft-Server-ActiveSync {
  134. include /etc/nginx/conf.d/includes/sogo_proxy_auth.conf;
  135. include /etc/nginx/conf.d/sogo_eas.active;
  136. proxy_connect_timeout 75;
  137. proxy_send_timeout 3600;
  138. proxy_read_timeout 3600;
  139. proxy_buffer_size 128k;
  140. proxy_buffers 64 512k;
  141. proxy_busy_buffers_size 512k;
  142. proxy_set_header X-Real-IP $remote_addr;
  143. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  144. proxy_set_header Host $http_host;
  145. client_body_buffer_size 512k;
  146. client_max_body_size 0;
  147. }
  148. location ^~ /SOGo {
  149. location ~* ^/SOGo/so/.*\.(xml|js|html|xhtml)$ {
  150. include /etc/nginx/conf.d/includes/sogo_proxy_auth.conf;
  151. include /etc/nginx/conf.d/sogo.active;
  152. proxy_set_header X-Real-IP $remote_addr;
  153. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  154. proxy_set_header Host $http_host;
  155. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  156. proxy_set_header x-webobjects-remote-host $remote_addr;
  157. proxy_set_header x-webobjects-server-name $server_name;
  158. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  159. proxy_set_header x-webobjects-server-port $server_port;
  160. proxy_hide_header Content-Type;
  161. add_header Content-Type text/plain;
  162. break;
  163. }
  164. include /etc/nginx/conf.d/includes/sogo_proxy_auth.conf;
  165. include /etc/nginx/conf.d/sogo.active;
  166. proxy_set_header X-Real-IP $remote_addr;
  167. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  168. proxy_set_header Host $http_host;
  169. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  170. proxy_set_header x-webobjects-remote-host $remote_addr;
  171. proxy_set_header x-webobjects-server-name $server_name;
  172. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  173. proxy_set_header x-webobjects-server-port $server_port;
  174. proxy_buffer_size 128k;
  175. proxy_buffers 64 512k;
  176. proxy_busy_buffers_size 512k;
  177. proxy_send_timeout 3600;
  178. proxy_read_timeout 3600;
  179. client_body_buffer_size 128k;
  180. client_max_body_size 0;
  181. break;
  182. }
  183. location ~* /sogo$ {
  184. return 301 $client_req_scheme://$http_host/SOGo;
  185. }
  186. location /SOGo.woa/WebServerResources/ {
  187. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  188. }
  189. location /.woa/WebServerResources/ {
  190. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  191. }
  192. location /SOGo/WebServerResources/ {
  193. alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  194. }
  195. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$) {
  196. alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  197. }
  198. include /etc/nginx/conf.d/site.*.custom;
  199. error_page 502 @awaitingupstream;
  200. location @awaitingupstream {
  201. rewrite ^(.*)$ /_status.502.html break;
  202. }
  203. location ~ ^/cache/(.*)$ {
  204. try_files $uri $uri/ /resource.php?file=$1;
  205. }