nginx.conf 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Server globals
  2. user www-data;
  3. worker_processes auto;
  4. worker_rlimit_nofile 65535;
  5. error_log /var/log/nginx/error.log;
  6. pid /run/nginx.pid;
  7. include /etc/nginx/modules-enabled/*.conf;
  8. # Worker config
  9. events {
  10. worker_connections 1024;
  11. use epoll;
  12. multi_accept on;
  13. }
  14. http {
  15. # Main settings
  16. sendfile on;
  17. tcp_nopush on;
  18. tcp_nodelay on;
  19. client_header_timeout 180s;
  20. client_body_timeout 180s;
  21. client_header_buffer_size 2k;
  22. client_body_buffer_size 256k;
  23. client_max_body_size 1024m;
  24. large_client_header_buffers 4 8k;
  25. send_timeout 60s;
  26. keepalive_timeout 30s;
  27. keepalive_requests 10000;
  28. reset_timedout_connection on;
  29. server_tokens off;
  30. server_name_in_redirect off;
  31. server_names_hash_max_size 512;
  32. server_names_hash_bucket_size 512;
  33. charset utf-8;
  34. # FastCGI settings
  35. fastcgi_buffers 512 4k;
  36. fastcgi_buffer_size 256k;
  37. fastcgi_busy_buffers_size 256k;
  38. fastcgi_temp_file_write_size 256k;
  39. fastcgi_connect_timeout 30s;
  40. fastcgi_read_timeout 300s;
  41. fastcgi_send_timeout 180s;
  42. fastcgi_cache_lock on;
  43. fastcgi_cache_lock_timeout 5s;
  44. fastcgi_cache_background_update on;
  45. fastcgi_cache_revalidate on;
  46. # Proxy settings
  47. proxy_redirect off;
  48. proxy_set_header Host $host;
  49. proxy_set_header X-Real-IP $remote_addr;
  50. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  51. proxy_pass_header Set-Cookie;
  52. proxy_buffers 256 4k;
  53. proxy_buffer_size 32k;
  54. proxy_busy_buffers_size 32k;
  55. proxy_temp_file_write_size 256k;
  56. proxy_connect_timeout 30s;
  57. proxy_read_timeout 300s;
  58. proxy_send_timeout 180s;
  59. # Log format
  60. log_format main '$remote_addr - $remote_user [$time_local] $request "$status" $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
  61. log_format bytes '$body_bytes_sent';
  62. log_not_found off;
  63. access_log off;
  64. # Mime settings
  65. include /etc/nginx/mime.types;
  66. default_type application/octet-stream;
  67. # Compression
  68. gzip on;
  69. gzip_vary on;
  70. gzip_static on;
  71. gzip_comp_level 6;
  72. gzip_min_length 1024;
  73. gzip_buffers 128 4k;
  74. gzip_http_version 1.1;
  75. gzip_types text/css text/javascript text/js text/plain text/richtext text/shtml text/x-component text/x-java-source text/x-markdown text/x-script text/xml image/bmp image/svg+xml image/vnd.microsoft.icon image/x-icon font/otf font/ttf font/x-woff multipart/bag multipart/mixed application/eot application/font application/font-sfnt application/font-woff application/javascript application/javascript-binast application/json application/ld+json application/manifest+json application/opentype application/otf application/rss+xml application/ttf application/truetype application/vnd.api+json application/vnd.ms-fontobject application/wasm application/xhtml+xml application/xml application/xml+rss application/x-httpd-cgi application/x-javascript application/x-opentype application/x-otf application/x-perl application/x-protobuf application/x-ttf;
  76. gzip_proxied any;
  77. # Cloudflare IPs
  78. include /etc/nginx/conf.d/cloudflare.inc;
  79. # SSL PCI compliance
  80. ssl_buffer_size 1369;
  81. ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA256";
  82. ssl_dhparam /etc/ssl/dhparam.pem;
  83. ssl_early_data on;
  84. ssl_ecdh_curve auto;
  85. ssl_prefer_server_ciphers on;
  86. ssl_protocols TLSv1.2 TLSv1.3;
  87. ssl_session_cache shared:SSL:20m;
  88. ssl_session_tickets on;
  89. ssl_session_timeout 7d;
  90. resolver 1.0.0.1 8.8.4.4 1.1.1.1 8.8.8.8 valid=300s ipv6=off;
  91. resolver_timeout 5s;
  92. # Error pages
  93. error_page 403 /error/404.html;
  94. error_page 404 /error/404.html;
  95. error_page 410 /error/410.html;
  96. error_page 500 501 502 503 504 505 /error/50x.html;
  97. # Proxy cache
  98. proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
  99. proxy_cache_key "$scheme$request_method$host$request_uri";
  100. proxy_temp_path /var/cache/nginx/temp;
  101. proxy_ignore_headers Cache-Control Expires;
  102. proxy_cache_use_stale error timeout invalid_header updating http_502;
  103. proxy_cache_valid any 1d;
  104. # FastCGI cache
  105. fastcgi_cache_path /var/cache/nginx/micro levels=1:2 keys_zone=microcache:10m inactive=30m max_size=1024m;
  106. fastcgi_cache_key "$scheme$request_method$host$request_uri";
  107. fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
  108. fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;
  109. add_header X-FastCGI-Cache $upstream_cache_status;
  110. # Cache bypass
  111. map $http_cookie $no_cache {
  112. default 0;
  113. ~SESS 1;
  114. ~wordpress_logged_in 1;
  115. }
  116. # File cache (static assets)
  117. open_file_cache max=10000 inactive=30s;
  118. open_file_cache_valid 60s;
  119. open_file_cache_min_uses 2;
  120. open_file_cache_errors off;
  121. # Wildcard include
  122. include /etc/nginx/conf.d/*.conf;
  123. include /etc/nginx/conf.d/domains/*.conf;
  124. }