微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

http – Nginx服务器内容gzip压缩无法正常工作

这是我的Nginx.conf中的部分,但我不知道为什么当我用gzip压缩检查器或http头检查时,内容不是压缩.

https://pasify.com

user              Nginx;
worker_processes  1;

error_log  /var/log/Nginx/error.log;
#error_log  /var/log/Nginx/error.log  notice;
#error_log  /var/log/Nginx/error.log  info;

pid        /var/run/Nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/Nginx/mime.types;

    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/Nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  0;
    #keepalive_requests 5;
    #keepalive_timeout  65;
    send_timeout 10m;

    # output compression saves bandwidth
    gzip  on;
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/RSS+xml application/atom+xml application/rdf+xml;

    gzip_buffers 16 8k;

    # disable gzip for certain browsers.
    gzip_disable MSIE [1-6].(?!.*SV1);

    # Load config files from the /etc/Nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/Nginx/conf.d/*.conf;

    ## Detect when HTTPS is used
    map $scheme $fastcgi_https {
      default off;
      https on;
    }

    client_max_body_size 20M;


}

我可以知道这是什么问题吗?

最佳答案
通过

gzip_disable MSIE [1-6].(?!.*SV1);

你已经为几乎任何有User-Agent数字的浏览器禁用了gzip,因为有两个独立的正则表达式:“MSIE”和“[1-6].(?!.* SV1)”.添加引号或更好地使用它:

gzip_disable msie6;

有关详情,请参见docs.

原文地址:https://www.jb51.cc/nginx/434341.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐