nginx 开启gzip 压缩资源

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无效
    }

}


                              
                            

 

posted @ 2018-12-04 15:06  eedc  阅读(407)  评论(0编辑  收藏  举报