How can I disable Nginx double gzip encoding when the backcgi backcgi sometimes serves gzipped with content encoding?
Is there some clever way to trick nginx into stopping gzip if the backend has already set the "content-encoding" header?
Nginx is configured to gzip output from php fastcgi backend.
This works great 99% of the time.
Except in a rare case, php will send the raw gzip file and add the header Content-Encoding: gzip
.
Nginx will unfortunately go straight ahead and try to gzip that content a second time.
Creates a double header Content-Encoding: gzip
Content-Encoding: gzip
and a double-encoded gzipped body.
Most modern browsers can handle this, Firefox, Chrome.
IE8 cannot, Safari mobile cannot, old Safari 5 for Windows cannot - they will instead show garbled gzipped content because it concatenates the content encoding headers and only decodes the gzipped body once.
Thanks for any ideas.
source to share