nginx.conf 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # Server globals
  2. user www-data;
  3. worker_processes auto;
  4. worker_rlimit_nofile 65535;
  5. timer_resolution 50ms; #In order to free some CPU cycles
  6. error_log /var/log/nginx/error.log crit;
  7. pid /var/run/nginx.pid;
  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 1m;
  20. client_body_timeout 1m;
  21. client_header_buffer_size 2k;
  22. client_body_buffer_size 256k;
  23. client_max_body_size 256m;
  24. large_client_header_buffers 4 8k;
  25. send_timeout 30;
  26. keepalive_timeout 60 60;
  27. reset_timedout_connection on;
  28. server_tokens off;
  29. server_name_in_redirect off;
  30. server_names_hash_max_size 512;
  31. server_names_hash_bucket_size 512;
  32. # Log format
  33. log_format main '$remote_addr - $remote_user [$time_local] $request '
  34. '"$status" $body_bytes_sent "$http_referer" '
  35. '"$http_user_agent" "$http_x_forwarded_for"';
  36. log_format bytes '$body_bytes_sent';
  37. #access_log /var/log/nginx/access.log main;
  38. access_log off;
  39. # Mime settings
  40. include /etc/nginx/mime.types;
  41. default_type application/octet-stream;
  42. # Compression
  43. gzip on;
  44. gzip_vary on;
  45. gzip_comp_level 9;
  46. gzip_min_length 512;
  47. gzip_buffers 8 64k;
  48. gzip_types text/plain text/css text/javascript text/js text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss application/x-font-ttf image/svg+xml font/opentype;
  49. gzip_proxied any;
  50. gzip_disable "MSIE [1-6]\.";
  51. # Proxy settings
  52. proxy_redirect off;
  53. proxy_set_header Host $host;
  54. proxy_set_header X-Real-IP $remote_addr;
  55. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  56. proxy_pass_header Set-Cookie;
  57. proxy_connect_timeout 90;
  58. proxy_send_timeout 90;
  59. proxy_read_timeout 90;
  60. proxy_buffers 32 4k;
  61. # Cloudflare https://www.cloudflare.com/ips
  62. set_real_ip_from 103.21.244.0/22;
  63. set_real_ip_from 103.22.200.0/22;
  64. set_real_ip_from 103.31.4.0/22;
  65. set_real_ip_from 104.16.0.0/12;
  66. set_real_ip_from 108.162.192.0/18;
  67. set_real_ip_from 131.0.72.0/22;
  68. set_real_ip_from 141.101.64.0/18;
  69. set_real_ip_from 162.158.0.0/15;
  70. set_real_ip_from 172.64.0.0/13;
  71. set_real_ip_from 173.245.48.0/20;
  72. set_real_ip_from 188.114.96.0/20;
  73. set_real_ip_from 190.93.240.0/20;
  74. set_real_ip_from 197.234.240.0/22;
  75. set_real_ip_from 198.41.128.0/17;
  76. set_real_ip_from 2400:cb00::/32;
  77. set_real_ip_from 2606:4700::/32;
  78. set_real_ip_from 2803:f800::/32;
  79. set_real_ip_from 2405:b500::/32;
  80. set_real_ip_from 2405:8100::/32;
  81. set_real_ip_from 2c0f:f248::/32;
  82. set_real_ip_from 2a06:98c0::/29;
  83. real_ip_header CF-Connecting-IP;
  84. # SSL PCI Compliance
  85. ssl_session_cache shared:SSL:10m;
  86. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  87. ssl_prefer_server_ciphers on;
  88. 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";
  89. # Error pages
  90. error_page 403 /error/403.html;
  91. error_page 404 /error/404.html;
  92. error_page 502 503 504 /error/50x.html;
  93. # Cache settings
  94. proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
  95. proxy_cache_key "$host$request_uri $cookie_user";
  96. proxy_temp_path /var/cache/nginx/temp;
  97. proxy_ignore_headers Expires Cache-Control;
  98. proxy_cache_use_stale error timeout invalid_header http_502;
  99. proxy_cache_valid any 1d;
  100. # Cache bypass
  101. map $http_cookie $no_cache {
  102. default 0;
  103. ~SESS 1;
  104. ~wordpress_logged_in 1;
  105. }
  106. # File cache settings
  107. open_file_cache max=10000 inactive=30s;
  108. open_file_cache_valid 60s;
  109. open_file_cache_min_uses 2;
  110. open_file_cache_errors off;
  111. # Wildcard include
  112. include /etc/nginx/conf.d/*.conf;
  113. }