nginx 开启gzip 压缩资源

233人浏览 / 0人评论
upstream sems {
    server 127.0.0.1:10171 weight=1 fail_timeout=0;
}

server {
    listen 80;
    server_name www.serve.com;

    location / {
        proxy_pass http://sems/dist/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;

        gzip on;
        gzip_comp_level 6; # 压缩比例,比例越大,压缩时间越长。默认是1
        gzip_types text/xml text/plain text/css application/javascript application/x-javascript application/rss+xml image/jpeg image/gif image/png; # 哪些文件可以被压缩
        gzip_disable "MSIE [1-6]\."; # IE6无效
    }

}

 

全部评论