How to disable Nginx double gzip encoding when fastcgi backend occasionally serves gzipped with content-encoding?

放肆的年华 提交于 2019-12-03 21:47:40

问题


Is there any clever way to trick nginx to stop gzip if the backend already has set the "content-encoding" header?

Nginx is configured to gzip the output from the php fastcgi backend.

This works great in 99% of the cases.

Except on rare occasion php will send a raw gzipped file and attach a Content-Encoding: gzip header.

Nginx unfortunately will go right ahead and try to gzip that content a second time.

The produces a double content-encoding: gzip content-encoding: gzip header and double-encoded gzipped body.

Most modern browsers can handle this, Firefox, Chrome.

IE8 cannot, Safari mobile cannot, old Safari 5 for Windows cannot - instead they will show garbled gzipped content because it merges the content-encoding headers and only decodes the gzipped body once.

Thanks for any ideas.


回答1:


Somewhere in nginx.conf where it applies (there should be a fastcgi_params file somewhere) :

fastcgi_param  HTTP_ACCEPT_ENCODING      "";

This will disable the encoding from the backend.

I hope that still Nginx will serve encoded content after this. (I am not sure)



来源:https://stackoverflow.com/questions/27918475/how-to-disable-nginx-double-gzip-encoding-when-fastcgi-backend-occasionally-serv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!