nginx.conf 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. user www www;
  2. worker_processes auto;
  3. error_log /data/wwwlogs/error_nginx.log crit;
  4. pid /var/run/nginx.pid;
  5. worker_rlimit_nofile 51200;
  6. events {
  7. use epoll;
  8. worker_connections 51200;
  9. multi_accept on;
  10. }
  11. http {
  12. include mime.types;
  13. default_type application/octet-stream;
  14. server_names_hash_bucket_size 128;
  15. client_header_buffer_size 32k;
  16. large_client_header_buffers 4 32k;
  17. client_max_body_size 1024m;
  18. client_body_buffer_size 10m;
  19. sendfile on;
  20. tcp_nopush on;
  21. keepalive_timeout 120;
  22. server_tokens off;
  23. tcp_nodelay on;
  24. fastcgi_connect_timeout 300;
  25. fastcgi_send_timeout 300;
  26. fastcgi_read_timeout 300;
  27. fastcgi_buffer_size 64k;
  28. fastcgi_buffers 4 64k;
  29. fastcgi_busy_buffers_size 128k;
  30. fastcgi_temp_file_write_size 128k;
  31. fastcgi_intercept_errors on;
  32. #Gzip Compression
  33. gzip on;
  34. gzip_buffers 16 8k;
  35. gzip_comp_level 6;
  36. gzip_http_version 1.1;
  37. gzip_min_length 256;
  38. gzip_proxied any;
  39. gzip_vary on;
  40. gzip_types
  41. text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
  42. text/javascript application/javascript application/x-javascript
  43. text/x-json application/json application/x-web-app-manifest+json
  44. text/css text/plain text/x-component
  45. font/opentype application/x-font-ttf application/vnd.ms-fontobject
  46. image/x-icon;
  47. gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  48. ##Brotli Compression
  49. #brotli on;
  50. #brotli_comp_level 6;
  51. #brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
  52. ##If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
  53. #open_file_cache max=1000 inactive=20s;
  54. #open_file_cache_valid 30s;
  55. #open_file_cache_min_uses 2;
  56. #open_file_cache_errors on;
  57. log_format json escape=json '{"@timestamp":"$time_iso8601",'
  58. '"server_addr":"$server_addr",'
  59. '"remote_addr":"$remote_addr",'
  60. '"scheme":"$scheme",'
  61. '"request_method":"$request_method",'
  62. '"request_uri": "$request_uri",'
  63. '"request_length": "$request_length",'
  64. '"uri": "$uri", '
  65. '"request_time":$request_time,'
  66. '"body_bytes_sent":$body_bytes_sent,'
  67. '"bytes_sent":$bytes_sent,'
  68. '"status":"$status",'
  69. '"upstream_time":"$upstream_response_time",'
  70. '"upstream_host":"$upstream_addr",'
  71. '"upstream_status":"$upstream_status",'
  72. '"host":"$host",'
  73. '"http_referer":"$http_referer",'
  74. '"http_user_agent":"$http_user_agent"'
  75. '}';
  76. ######################## default ############################
  77. server {
  78. listen 80;
  79. server_name _;
  80. access_log /data/wwwlogs/access_nginx.log combined;
  81. root /data/wwwroot/default;
  82. index index.html index.htm index.php;
  83. #error_page 404 /404.html;
  84. #error_page 502 /502.html;
  85. location /nginx_status {
  86. stub_status on;
  87. access_log off;
  88. allow 127.0.0.1;
  89. deny all;
  90. }
  91. location ~ [^/]\.php(/|$) {
  92. #fastcgi_pass remote_php_ip:9000;
  93. fastcgi_pass unix:/dev/shm/php-cgi.sock;
  94. fastcgi_index index.php;
  95. include fastcgi.conf;
  96. }
  97. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
  98. expires 30d;
  99. access_log off;
  100. }
  101. location ~ .*\.(js|css)?$ {
  102. expires 7d;
  103. access_log off;
  104. }
  105. location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {
  106. deny all;
  107. }
  108. location /.well-known {
  109. allow all;
  110. }
  111. }
  112. ########################## vhost #############################
  113. include vhost/*.conf;
  114. }