【nginx】配置

server {
  listen 80;
  server_name hocalhost;

  location / {
    root /usr/share/nginx/html;
    index index.html index.html;
  }

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root /usr/share/nginx/html;
  }
}

图片

server {
  loction ~ .*\.(jpg|png|gif)$ {
    gzip on; 启用压缩
    gzip_http_version 1.1; http协议
    gzip_comp_level 5; 压缩比例
    gzip_types image/jpeg image/png image/jpg; 压缩内容类型
    root /data/images; 目录
  }
}

HTML

server {
  loction ~ .*\.(html|js|css)$ {
    gzip on; 启用压缩
    gzip_min_length 1k;
    gzip_http_version 1.1; http协议
    gzip_comp_level 9; 压缩比例
    gzip_types text/css application/javascript
    root /data/html; 目录
  }
}

猜你喜欢

转载自www.cnblogs.com/wuxianqiang/p/10591733.html