nginx.conf.j2 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. include /etc/nginx/conf.d/*.conf;
  20. # map-size.conf:
  21. map_hash_max_size 256;
  22. map_hash_bucket_size 256;
  23. # site.conf:
  24. proxy_cache_path /tmp levels=1:2 keys_zone=sogo:10m inactive=24h max_size=1g;
  25. server_names_hash_max_size 512;
  26. server_names_hash_bucket_size 128;
  27. map $http_x_forwarded_proto $client_req_scheme {
  28. default $scheme;
  29. https https;
  30. }
  31. # Default
  32. server {
  33. listen 127.0.0.1:65510; # sogo-auth verify internal
  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. {% if not DISABLE_IPv6 %}
  37. listen [::]:{{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  38. listen [::]:{{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  39. {%endif%}
  40. http2 on;
  41. ssl_certificate /etc/ssl/mail/cert.pem;
  42. ssl_certificate_key /etc/ssl/mail/key.pem;
  43. server_name {{ MAILCOW_HOSTNAME }} autodiscover.* autoconfig.* {{ ADDITIONAL_SERVER_NAMES }};
  44. include /etc/nginx/includes/sites-default.conf;
  45. }
  46. # rspamd dynmaps:
  47. server {
  48. listen 8081;
  49. {% if not DISABLE_IPv6 %}
  50. listen [::]:8081;
  51. {%endif%}
  52. index index.php index.html;
  53. server_name _;
  54. error_log /var/log/nginx/error.log;
  55. access_log /var/log/nginx/access.log;
  56. root /dynmaps;
  57. location ~ \.php$ {
  58. try_files $uri =404;
  59. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  60. fastcgi_pass {{ PHPFPMHOST }}:9001;
  61. fastcgi_index index.php;
  62. include fastcgi_params;
  63. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  64. fastcgi_param PATH_INFO $fastcgi_path_info;
  65. }
  66. }
  67. # rspamd meta_exporter:
  68. server {
  69. listen 9081;
  70. index index.php index.html;
  71. server_name _;
  72. error_log /var/log/nginx/error.log;
  73. access_log /var/log/nginx/access.log;
  74. root /meta_exporter;
  75. client_max_body_size 10M;
  76. location ~ \.php$ {
  77. client_max_body_size 10M;
  78. try_files $uri =404;
  79. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  80. fastcgi_pass {{ PHPFPMHOST }}:9001;
  81. fastcgi_index pipe.php;
  82. include fastcgi_params;
  83. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  84. fastcgi_param PATH_INFO $fastcgi_path_info;
  85. }
  86. }
  87. {% for cert in valid_cert_dirs %}
  88. server {
  89. listen {{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  90. listen {{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  91. {% if not DISABLE_IPv6 %}
  92. listen [::]:{{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  93. listen [::]:{{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  94. {%endif%}
  95. http2 on;
  96. ssl_certificate {{ cert.cert_path }}cert.pem;
  97. ssl_certificate_key {{ cert.cert_path }}key.pem;
  98. server_name {{ cert.domains }};
  99. include /etc/nginx/includes/sites-default.conf;
  100. }
  101. {% endfor %}
  102. }