nginx.conf 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. user nginx;
  2. worker_processes 1;
  3. events {
  4. worker_connections 1024;
  5. }
  6. error_log /var/log/nginx/error.log warn;
  7. pid /var/run/nginx.pid;
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. sendfile on;
  12. keepalive_timeout 65;
  13. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. '$status $body_bytes_sent "$http_referer" '
  15. '"$http_user_agent" "$http_x_forwarded_for"';
  16. # access_log /var/log/nginx/access.log main;
  17. gzip on;
  18. gzip_min_length 1k; # 设置允许压缩的页面最小字节数
  19. gzip_buffers 4 16k; # 用来存储 gzip 的压缩结果
  20. gzip_http_version 1.1; # 识别 HTTP 协议版本
  21. gzip_comp_level 2; # 设置 gzip 的压缩比 1-9。1 压缩比最小但最快,而 9 相反
  22. gzip_types text/plain application/x-javascript text/css application/xml application/javascript; # 指定压缩类型
  23. gzip_proxied any; # 无论后端服务器的 headers 头返回什么信息,都无条件启用压缩
  24. include /etc/nginx/conf.d/*.conf; ## 加载该目录下的其它 Nginx 配置文件
  25. }