nginx.conf.j2 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. user nginx;
  2. worker_processes auto;
  3. error_log /var/log/nginx/error.log notice;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on;
  16. #tcp_nopush on;
  17. keepalive_timeout 65;
  18. #gzip on;
  19. # map-size.conf:
  20. map_hash_max_size 256;
  21. map_hash_bucket_size 256;
  22. # site.conf:
  23. proxy_cache_path /tmp levels=1:2 keys_zone=sogo:10m inactive=24h max_size=1g;
  24. server_names_hash_max_size 512;
  25. server_names_hash_bucket_size 128;
  26. map $http_x_forwarded_proto $client_req_scheme {
  27. default $scheme;
  28. https https;
  29. }
  30. # Default
  31. server {
  32. listen 127.0.0.1:65510; # sogo-auth verify internal
  33. listen {{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  34. listen [::]:{{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  35. listen {{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  36. listen [::]:{{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  37. http2 on;
  38. ssl_certificate /etc/ssl/mail/cert.pem;
  39. ssl_certificate_key /etc/ssl/mail/key.pem;
  40. server_name {{ MAILCOW_HOSTNAME }} autodiscover.* autoconfig.* {{ ADDITIONAL_SERVER_NAMES }};
  41. include /etc/nginx/includes/sites-default.conf;
  42. }
  43. # rspamd dynmaps:
  44. server {
  45. listen 8081;
  46. listen [::]:8081;
  47. index index.php index.html;
  48. server_name _;
  49. error_log /var/log/nginx/error.log;
  50. access_log /var/log/nginx/access.log;
  51. root /dynmaps;
  52. location ~ \.php$ {
  53. try_files $uri =404;
  54. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  55. fastcgi_pass {{ PHPFPMHOST }}:9001;
  56. fastcgi_index index.php;
  57. include fastcgi_params;
  58. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  59. fastcgi_param PATH_INFO $fastcgi_path_info;
  60. }
  61. }
  62. # rspamd meta_exporter:
  63. server {
  64. listen 9081;
  65. index index.php index.html;
  66. server_name _;
  67. error_log /var/log/nginx/error.log;
  68. access_log /var/log/nginx/access.log;
  69. root /meta_exporter;
  70. client_max_body_size 10M;
  71. location ~ \.php$ {
  72. client_max_body_size 10M;
  73. try_files $uri =404;
  74. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  75. fastcgi_pass {{ PHPFPMHOST }}:9001;
  76. fastcgi_index pipe.php;
  77. include fastcgi_params;
  78. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  79. fastcgi_param PATH_INFO $fastcgi_path_info;
  80. }
  81. }
  82. {% for cert in valid_cert_dirs %}
  83. server {
  84. listen {{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  85. listen [::]:{{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  86. listen {{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  87. listen [::]:{{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  88. http2 on;
  89. ssl_certificate {{ cert.cert_path }}cert.pem;
  90. ssl_certificate_key {{ cert.cert_path }}key.pem;
  91. server_name {{ cert.domains }};
  92. include /etc/nginx/includes/sites-default.conf;
  93. }
  94. {% endfor %}
  95. }