nginx.conf.j2 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 {{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  35. {% if not DISABLE_IPv6 %}
  36. listen [::]:{{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  37. listen [::]:{{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  38. {%endif%}
  39. http2 on;
  40. ssl_certificate /etc/ssl/mail/cert.pem;
  41. ssl_certificate_key /etc/ssl/mail/key.pem;
  42. server_name {{ MAILCOW_HOSTNAME }} autodiscover.* autoconfig.* {{ ADDITIONAL_SERVER_NAMES }};
  43. include /etc/nginx/includes/sites-default.conf;
  44. }
  45. # rspamd dynmaps:
  46. server {
  47. listen 8081;
  48. {% if not DISABLE_IPv6 %}
  49. listen [::]:8081;
  50. {%endif%}
  51. index index.php index.html;
  52. server_name _;
  53. error_log /var/log/nginx/error.log;
  54. access_log /var/log/nginx/access.log;
  55. root /dynmaps;
  56. location ~ \.php$ {
  57. try_files $uri =404;
  58. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  59. fastcgi_pass {{ PHPFPMHOST }}:9001;
  60. fastcgi_index index.php;
  61. include fastcgi_params;
  62. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  63. fastcgi_param PATH_INFO $fastcgi_path_info;
  64. }
  65. }
  66. # rspamd meta_exporter:
  67. server {
  68. listen 9081;
  69. index index.php index.html;
  70. server_name _;
  71. error_log /var/log/nginx/error.log;
  72. access_log /var/log/nginx/access.log;
  73. root /meta_exporter;
  74. client_max_body_size 10M;
  75. location ~ \.php$ {
  76. client_max_body_size 10M;
  77. try_files $uri =404;
  78. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  79. fastcgi_pass {{ PHPFPMHOST }}:9001;
  80. fastcgi_index pipe.php;
  81. include fastcgi_params;
  82. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  83. fastcgi_param PATH_INFO $fastcgi_path_info;
  84. }
  85. }
  86. server {
  87. listen 9082 ssl http2;
  88. ssl_certificate /etc/ssl/mail/cert.pem;
  89. ssl_certificate_key /etc/ssl/mail/key.pem;
  90. index mailcowauth.php;
  91. server_name _;
  92. error_log /var/log/nginx/error.log;
  93. access_log /var/log/nginx/access.log;
  94. root /mailcowauth;
  95. client_max_body_size 10M;
  96. location ~ \.php$ {
  97. client_max_body_size 10M;
  98. try_files $uri =404;
  99. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  100. fastcgi_pass phpfpm:9001;
  101. include fastcgi_params;
  102. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  103. fastcgi_param PATH_INFO $fastcgi_path_info;
  104. }
  105. }
  106. {% for cert in valid_cert_dirs %}
  107. server {
  108. listen {{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  109. listen {{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  110. {% if not DISABLE_IPv6 %}
  111. listen [::]:{{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  112. listen [::]:{{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  113. {%endif%}
  114. http2 on;
  115. ssl_certificate {{ cert.cert_path }}cert.pem;
  116. ssl_certificate_key {{ cert.cert_path }}key.pem;
  117. server_name {{ cert.domains }};
  118. include /etc/nginx/includes/sites-default.conf;
  119. }
  120. {% endfor %}
  121. include /etc/nginx/conf.d/*.conf;
  122. }