Nginx 关不掉 gzip 是为什么?

2014-10-16 22:37:42 +08:00
 snw
尝试反代Google,由于需要进行替换,所以要关掉gzip。我在server段加了以下两句:
gzip off;
gzip_static off;

测试后发现,
(1) IE11访问是不压缩的,Response header的Transfer-Encoding是chunked,代码被成功替换。
(2) 用orbit downloader下载下来的文件也是成功替换。
(3) 但是用Firefox 33和Chrome 38访问,Response header却有Content-Encoding: "gzip",代码没有被替换。

我甚至尝试在编译时去除 --with-http_gunzip_module 和 --with-http_gzip_static_module ,结果Response header还是有gzip。

这究竟是什么原因?


nginx的配置文件:
https://github.com/shenyqwilliam/google-reverse-proxy/blob/master/google-reverse-proxy.conf

Demo网站(请忽略证书问题):
https://vmb.host.lith.tk/

nginx信息:
nginx version: nginx/1.6.2
built by gcc 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --add-module=/usr/local/src/ngx_http_substitutions_filter_module/
3315 次点击
所在节点    问与答
2 条回复
yfgeek
2020-05-20 01:35:20 +08:00
参考这个文章:
https://ialloc.org/blog/how-nginx-gzip-works/#vary-accept-encoding
```
proxy_set_header Accept-Encoding "";
```
就好了
snw
2020-05-20 07:59:22 +08:00
@yfgeek
问题补充写了,加了这句也没用。
几年前的事,现在无法再验证。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/139405

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX