Nginx – Enforcing No Gzip on Nginx

gzipnginxreverse-proxy

I need to disable gzip in some cases, regardless of client's Accept-* request headers.

My Nginx's conf entry has the following directives:

gzip off;

more_clear_input_headers -t 'text/html' Accept Accept-Encoding;

proxy_set_header Accept "";
proxy_set_header Accept-Encoding "";

However, the following curl:

curl '$URL' 
-H 'Pragma: no-cache' 
-H 'Accept-Encoding: gzip, deflate, sdch' 
-H 'Accept-Language: en-US,en;q=0.8,he;q=0.6' 
-H 'Upgrade-Insecure-Requests: 1' 
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36' 
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' 
-H 'Cache-Control: no-cache' 
-H 'Cookie:  "$COOKIE"'
-H 'Connection: keep-alive'  -v > /dev/null

Results with:

< HTTP/1.1 200 OK
< Cache-Control: no-cache, no-store, private
< Content-Encoding: gzip
< Content-Type: text/html;charset=utf-8
< Date: Thu, 01 Sep 2016 07:13:30 GMT
< Expires: -1
< Server: Reblaze Secure Web Gateway
< Set-Cookie: ...
< Set-Cookie: ...
< Set-Cookie: ...
< Set-Cookie: ...
< Set-Cookie: ...
< Set-Cookie: ...
< Set-Cookie: ...
< Vary: User-Agent
< Content-Length: 55455
< Connection: keep-alive

Note, the responding server is proxied by this Nginx.

Best Answer

Apparently, this is not an Nginx "misbehaviour" rather, a proxied device, F5 BigIP in this case, which is configured to compress responses regardless of request headers, as long as the User-Agent header matches certain patterns.