site.conf 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. server_tokens off;
  2. proxy_cache_path /tmp levels=1:2 keys_zone=sogo:10m inactive=24h max_size=1g;
  3. server_names_hash_bucket_size 64;
  4. map $http_x_forwarded_proto $client_req_scheme {
  5. default $scheme;
  6. https https;
  7. }
  8. server {
  9. include /etc/nginx/mime.types;
  10. charset utf-8;
  11. override_charset on;
  12. add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
  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";
  18. add_header X-Permitted-Cross-Domain-Policies none;
  19. index index.php index.html;
  20. include /etc/nginx/conf.d/listen_plain.active;
  21. include /etc/nginx/conf.d/server_name.active;
  22. error_log /var/log/nginx/error.log;
  23. access_log /var/log/nginx/access.log;
  24. absolute_redirect off;
  25. root /web;
  26. location ~ ^/api/v1/(.*)$ {
  27. try_files $uri $uri/ /json_api.php?query=$1;
  28. }
  29. location ^~ /.well-known/acme-challenge/ {
  30. allow all;
  31. default_type "text/plain";
  32. }
  33. # If behind reverse proxy, forwards the correct IP
  34. set_real_ip_from 10.0.0.0/8;
  35. set_real_ip_from 172.16.0.0/12;
  36. set_real_ip_from 192.168.0.0/16;
  37. set_real_ip_from fc00::/7;
  38. real_ip_header X-Forwarded-For;
  39. real_ip_recursive on;
  40. rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
  41. rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
  42. location ^~ /principals {
  43. return 301 /SOGo/dav;
  44. }
  45. location ~ \.php$ {
  46. try_files $uri =404;
  47. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  48. fastcgi_pass phpfpm:9000;
  49. fastcgi_index index.php;
  50. include /etc/nginx/fastcgi_params;
  51. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  52. fastcgi_param PATH_INFO $fastcgi_path_info;
  53. fastcgi_param PHP_VALUE "max_execution_time = 1200
  54. max_input_time = 1200
  55. memory_limit = 64M";
  56. fastcgi_read_timeout 1200;
  57. }
  58. location /rspamd/ {
  59. proxy_pass http://rspamd:11334/;
  60. proxy_set_header Host $http_host;
  61. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  62. proxy_set_header X-Real-IP $remote_addr;
  63. proxy_redirect off;
  64. }
  65. location ~* ^/Autodiscover/Autodiscover.xml {
  66. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  67. fastcgi_pass phpfpm:9000;
  68. include /etc/nginx/fastcgi_params;
  69. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  70. try_files /autodiscover.php =404;
  71. }
  72. location ~* ^/Autodiscover/Autodiscover.json {
  73. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  74. fastcgi_pass phpfpm:9000;
  75. include /etc/nginx/fastcgi_params;
  76. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  77. try_files /autodiscover-json.php =404;
  78. }
  79. location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
  80. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  81. fastcgi_pass phpfpm:9000;
  82. include /etc/nginx/fastcgi_params;
  83. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  84. try_files /autoconfig.php =404;
  85. }
  86. location ^~ /Microsoft-Server-ActiveSync {
  87. proxy_pass http://sogo:20000/SOGo/Microsoft-Server-ActiveSync;
  88. proxy_connect_timeout 1000;
  89. proxy_next_upstream timeout error;
  90. proxy_send_timeout 1000;
  91. proxy_read_timeout 1000;
  92. proxy_buffer_size 8k;
  93. proxy_buffers 4 32k;
  94. proxy_temp_file_write_size 64k;
  95. proxy_busy_buffers_size 64k;
  96. proxy_set_header X-Real-IP $remote_addr;
  97. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  98. proxy_set_header Host $http_host;
  99. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  100. proxy_set_header x-webobjects-remote-host $remote_addr;
  101. proxy_set_header x-webobjects-server-name $server_name;
  102. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  103. proxy_set_header x-webobjects-server-port $server_port;
  104. client_body_buffer_size 128k;
  105. client_max_body_size 0;
  106. }
  107. location ^~ /SOGo {
  108. proxy_pass http://sogo:20000;
  109. proxy_set_header X-Real-IP $remote_addr;
  110. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  111. proxy_set_header Host $http_host;
  112. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  113. proxy_set_header x-webobjects-remote-host $remote_addr;
  114. proxy_set_header x-webobjects-server-name $server_name;
  115. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  116. proxy_set_header x-webobjects-server-port $server_port;
  117. client_body_buffer_size 128k;
  118. client_max_body_size 0;
  119. break;
  120. }
  121. location /SOGo.woa/WebServerResources/ {
  122. proxy_pass http://sogo:9192/WebServerResources/;
  123. proxy_set_header Host $http_host;
  124. proxy_cache sogo;
  125. proxy_cache_valid 200 1d;
  126. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  127. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  128. allow all;
  129. }
  130. location /.woa/WebServerResources/ {
  131. proxy_pass http://sogo:9192/WebServerResources/;
  132. proxy_set_header Host $http_host;
  133. proxy_cache sogo;
  134. proxy_cache_valid 200 1d;
  135. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  136. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  137. allow all;
  138. }
  139. location /SOGo/WebServerResources/ {
  140. proxy_pass http://sogo:9192/WebServerResources/;
  141. proxy_set_header Host $http_host;
  142. proxy_cache sogo;
  143. proxy_cache_valid 200 1d;
  144. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  145. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  146. allow all;
  147. }
  148. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$ {
  149. proxy_pass http://sogo:9192/$1.SOGo/Resources/$2;
  150. proxy_set_header Host $http_host;
  151. proxy_cache sogo;
  152. proxy_cache_valid 200 1d;
  153. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  154. #alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  155. }
  156. include /etc/nginx/conf.d/site.*.custom;
  157. }
  158. server {
  159. include /etc/nginx/mime.types;
  160. charset utf-8;
  161. override_charset on;
  162. ssl on;
  163. ssl_certificate /etc/ssl/mail/cert.pem;
  164. ssl_certificate_key /etc/ssl/mail/key.pem;
  165. ssl_protocols TLSv1.2;
  166. 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';
  167. ssl_prefer_server_ciphers on;
  168. ssl_session_cache shared:SSL:50m;
  169. ssl_session_timeout 1d;
  170. ssl_session_tickets off;
  171. add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
  172. add_header X-Content-Type-Options nosniff;
  173. add_header X-XSS-Protection "1; mode=block";
  174. add_header X-Robots-Tag none;
  175. add_header X-Download-Options noopen;
  176. add_header X-Frame-Options "SAMEORIGIN";
  177. add_header X-Permitted-Cross-Domain-Policies none;
  178. index index.php index.html;
  179. include /etc/nginx/conf.d/listen_ssl.active;
  180. include /etc/nginx/conf.d/server_name.active;
  181. error_log /var/log/nginx/error.log;
  182. access_log /var/log/nginx/access.log;
  183. absolute_redirect off;
  184. root /web;
  185. location ~ ^/api/v1/(.*)$ {
  186. try_files $uri $uri/ /json_api.php?query=$1;
  187. }
  188. location ^~ /.well-known/acme-challenge/ {
  189. allow all;
  190. default_type "text/plain";
  191. }
  192. # If behind reverse proxy, forwards the correct IP
  193. set_real_ip_from 10.0.0.0/8;
  194. set_real_ip_from 172.16.0.0/12;
  195. set_real_ip_from 192.168.0.0/16;
  196. set_real_ip_from fc00::/7;
  197. real_ip_header X-Forwarded-For;
  198. real_ip_recursive on;
  199. rewrite ^/.well-known/caldav$ /SOGo/dav/ permanent;
  200. rewrite ^/.well-known/carddav$ /SOGo/dav/ permanent;
  201. location ^~ /principals {
  202. return 301 /SOGo/dav;
  203. }
  204. location ~ \.php$ {
  205. try_files $uri =404;
  206. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  207. fastcgi_pass phpfpm:9000;
  208. fastcgi_index index.php;
  209. include /etc/nginx/fastcgi_params;
  210. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  211. fastcgi_param PATH_INFO $fastcgi_path_info;
  212. fastcgi_param PHP_VALUE "max_execution_time = 1200
  213. max_input_time = 1200
  214. memory_limit = 64M";
  215. fastcgi_read_timeout 1200;
  216. }
  217. location /rspamd/ {
  218. proxy_pass http://rspamd:11334/;
  219. proxy_set_header Host $http_host;
  220. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  221. proxy_set_header X-Real-IP $remote_addr;
  222. proxy_redirect off;
  223. }
  224. location ~* ^/Autodiscover/Autodiscover.xml {
  225. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  226. fastcgi_pass phpfpm:9000;
  227. include /etc/nginx/fastcgi_params;
  228. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  229. try_files /autodiscover.php =404;
  230. }
  231. location ~* ^/Autodiscover/Autodiscover.json {
  232. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  233. fastcgi_pass phpfpm:9000;
  234. include /etc/nginx/fastcgi_params;
  235. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  236. try_files /autodiscover-json.php =404;
  237. }
  238. location ~ /(?:m|M)ail/(?:c|C)onfig-v1.1.xml {
  239. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  240. fastcgi_pass phpfpm:9000;
  241. include /etc/nginx/fastcgi_params;
  242. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  243. try_files /autoconfig.php =404;
  244. }
  245. location ^~ /Microsoft-Server-ActiveSync {
  246. proxy_pass http://sogo:20000/SOGo/Microsoft-Server-ActiveSync;
  247. proxy_connect_timeout 1000;
  248. proxy_next_upstream timeout error;
  249. proxy_send_timeout 1000;
  250. proxy_read_timeout 1000;
  251. proxy_buffer_size 8k;
  252. proxy_buffers 4 32k;
  253. proxy_temp_file_write_size 64k;
  254. proxy_busy_buffers_size 64k;
  255. proxy_set_header X-Real-IP $remote_addr;
  256. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  257. proxy_set_header Host $http_host;
  258. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  259. proxy_set_header x-webobjects-remote-host $remote_addr;
  260. proxy_set_header x-webobjects-server-name $server_name;
  261. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  262. proxy_set_header x-webobjects-server-port $server_port;
  263. client_body_buffer_size 128k;
  264. client_max_body_size 0;
  265. }
  266. location ^~ /SOGo {
  267. proxy_pass http://sogo:20000;
  268. proxy_set_header X-Real-IP $remote_addr;
  269. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  270. proxy_set_header Host $http_host;
  271. proxy_set_header x-webobjects-server-protocol HTTP/1.0;
  272. proxy_set_header x-webobjects-remote-host $remote_addr;
  273. proxy_set_header x-webobjects-server-name $server_name;
  274. proxy_set_header x-webobjects-server-url $client_req_scheme://$http_host;
  275. proxy_set_header x-webobjects-server-port $server_port;
  276. client_body_buffer_size 128k;
  277. client_max_body_size 0;
  278. break;
  279. }
  280. location /SOGo.woa/WebServerResources/ {
  281. proxy_pass http://sogo:9192/WebServerResources/;
  282. proxy_set_header Host $http_host;
  283. proxy_cache sogo;
  284. proxy_cache_valid 200 1d;
  285. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  286. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  287. allow all;
  288. }
  289. location /.woa/WebServerResources/ {
  290. proxy_pass http://sogo:9192/WebServerResources/;
  291. proxy_set_header Host $http_host;
  292. proxy_cache sogo;
  293. proxy_cache_valid 200 1d;
  294. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  295. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  296. allow all;
  297. }
  298. location /SOGo/WebServerResources/ {
  299. proxy_pass http://sogo:9192/WebServerResources/;
  300. proxy_set_header Host $http_host;
  301. proxy_cache sogo;
  302. proxy_cache_valid 200 1d;
  303. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  304. #alias /usr/lib/GNUstep/SOGo/WebServerResources/;
  305. allow all;
  306. }
  307. location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$ {
  308. proxy_pass http://sogo:9192/$1.SOGo/Resources/$2;
  309. proxy_set_header Host $http_host;
  310. proxy_cache sogo;
  311. proxy_cache_valid 200 1d;
  312. proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
  313. #alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
  314. }
  315. include /etc/nginx/conf.d/site.*.custom;
  316. }