nginx.conf.j2 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. server {
  83. listen 9082 ssl http2;
  84. ssl_certificate /etc/ssl/mail/cert.pem;
  85. ssl_certificate_key /etc/ssl/mail/key.pem;
  86. index mailcowauth.php;
  87. server_name _;
  88. error_log /var/log/nginx/error.log;
  89. access_log /var/log/nginx/access.log;
  90. root /mailcowauth;
  91. client_max_body_size 10M;
  92. location ~ \.php$ {
  93. client_max_body_size 10M;
  94. try_files $uri =404;
  95. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  96. fastcgi_pass phpfpm:9001;
  97. include fastcgi_params;
  98. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  99. fastcgi_param PATH_INFO $fastcgi_path_info;
  100. }
  101. }
  102. {% for cert in valid_cert_dirs %}
  103. server {
  104. listen {{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  105. listen [::]:{{ HTTP_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%};
  106. listen {{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  107. listen [::]:{{ HTTPS_PORT }}{% if NGINX_USE_PROXY_PROTOCOL %} proxy_protocol{%endif%} ssl;
  108. http2 on;
  109. ssl_certificate {{ cert.cert_path }}cert.pem;
  110. ssl_certificate_key {{ cert.cert_path }}key.pem;
  111. server_name {{ cert.domains }};
  112. include /etc/nginx/includes/sites-default.conf;
  113. }
  114. {% endfor %}
  115. }