nginx.conf 767 B

123456789101112131415161718
  1. server {
  2. listen 80 default_server;
  3. server_name _;
  4. gzip on;
  5. gzip_min_length 1k; # 设置允许压缩的页面最小字节数
  6. gzip_buffers 4 16k; # 用来存储 gzip 的压缩结果
  7. gzip_http_version 1.1; # 识别 HTTP 协议版本
  8. gzip_comp_level 2; # 设置 gzip 的压缩比 1-9。1 压缩比最小但最快,而 9 相反
  9. gzip_types text/plain application/x-javascript text/css application/xml application/javascript; # 指定压缩类型
  10. gzip_proxied any; # 无论后端服务器的 headers 头返回什么信息,都无条件启用压缩
  11. location / { ## 前端项目
  12. root /usr/share/nginx/html/;
  13. index index.html index.htm;
  14. try_files $uri $uri/ /index.html;
  15. }
  16. }