nginx.conf 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # Server globals
  2. user www-data;
  3. worker_processes 2;
  4. error_log /var/log/nginx/error.log;
  5. pid /var/run/nginx.pid;
  6. # Worker config
  7. events {
  8. worker_connections 1024;
  9. use epoll;
  10. }
  11. http {
  12. # Main settings
  13. sendfile on;
  14. tcp_nopush on;
  15. tcp_nodelay on;
  16. client_header_timeout 1m;
  17. client_body_timeout 1m;
  18. client_header_buffer_size 2k;
  19. client_body_buffer_size 256k;
  20. client_max_body_size 100m;
  21. large_client_header_buffers 4 8k;
  22. send_timeout 30;
  23. keepalive_timeout 60 60;
  24. reset_timedout_connection on;
  25. server_tokens off;
  26. server_name_in_redirect off;
  27. server_names_hash_max_size 512;
  28. server_names_hash_bucket_size 512;
  29. # Log format
  30. log_format main '$remote_addr - $remote_user [$time_local] $request '
  31. '"$status" $body_bytes_sent "$http_referer" '
  32. '"$http_user_agent" "$http_x_forwarded_for"';
  33. log_format bytes '$body_bytes_sent';
  34. #access_log /var/log/nginx/access.log main;
  35. access_log off;
  36. # Mime settings
  37. include /etc/nginx/mime.types;
  38. default_type application/octet-stream;
  39. # Compression
  40. gzip on;
  41. gzip_comp_level 9;
  42. gzip_min_length 512;
  43. gzip_buffers 8 64k;
  44. gzip_types text/plain text/css text/javascript
  45. application/x-javascript;
  46. gzip_proxied any;
  47. # Proxy settings
  48. proxy_redirect off;
  49. proxy_set_header Host $host;
  50. proxy_set_header X-Real-IP $remote_addr;
  51. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  52. proxy_pass_header Set-Cookie;
  53. proxy_connect_timeout 90;
  54. proxy_send_timeout 90;
  55. proxy_read_timeout 90;
  56. proxy_buffers 32 4k;
  57. # Cloudflare https://www.cloudflare.com/ips
  58. set_real_ip_from 199.27.128.0/21;
  59. set_real_ip_from 173.245.48.0/20;
  60. set_real_ip_from 103.21.244.0/22;
  61. set_real_ip_from 103.22.200.0/22;
  62. set_real_ip_from 103.31.4.0/22;
  63. set_real_ip_from 141.101.64.0/18;
  64. set_real_ip_from 108.162.192.0/18;
  65. set_real_ip_from 190.93.240.0/20;
  66. set_real_ip_from 188.114.96.0/20;
  67. set_real_ip_from 197.234.240.0/22;
  68. set_real_ip_from 198.41.128.0/17;
  69. set_real_ip_from 162.158.0.0/15;
  70. set_real_ip_from 104.16.0.0/12;
  71. set_real_ip_from 172.64.0.0/13;
  72. #set_real_ip_from 2400:cb00::/32;
  73. #set_real_ip_from 2606:4700::/32;
  74. #set_real_ip_from 2803:f800::/32;
  75. #set_real_ip_from 2405:b500::/32;
  76. #set_real_ip_from 2405:8100::/32;
  77. real_ip_header CF-Connecting-IP;
  78. # SSL PCI Compliance
  79. ssl_session_cache shared:SSL:10m;
  80. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  81. ssl_prefer_server_ciphers on;
  82. ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
  83. # Error pages
  84. error_page 403 /error/403.html;
  85. error_page 404 /error/404.html;
  86. error_page 502 503 504 /error/50x.html;
  87. # Cache
  88. proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=512m;
  89. proxy_cache_key "$host$request_uri $cookie_user";
  90. proxy_temp_path /var/cache/nginx/temp;
  91. proxy_ignore_headers Expires Cache-Control;
  92. proxy_cache_use_stale error timeout invalid_header http_502;
  93. proxy_cache_valid any 3d;
  94. map $http_cookie $no_cache {
  95. default 0;
  96. ~SESS 1;
  97. ~wordpress_logged_in 1;
  98. }
  99. # Wildcard include
  100. include /etc/nginx/conf.d/*.conf;
  101. }