V
V
Valery2017-06-02 17:19:00
Nginx
Valery, 2017-06-02 17:19:00

Why does Nginx disable gzip when setting User-Agent?

There is nginx living in the nginx-alpine docker container.

# gzip.conf
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_buffers 16 8k;
gzip_http_version 1.0;
gzip_min_length 10;
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype;

Everything seems to be standard. Tried to play with different values: the result is the same. Gzip is disabled in the browser.
I take the request emulator and make a request without the User-Agent header:
Cache-Control: max-age=0
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/plain
Date: Fri, 02 Jun 2017 14:16:44 GMT
Etag: W/"59316a61-25a"
Expires: Fri, 02 Jun 2017 14:16:44 GMT
Last-Modified: Fri, 02 Jun 2017 13:38:41 GMT
Server: nginx
Transfer-Encoding: chunked
Vary: Accept-Encoding

As you can see, Content-Encoding is in place. But if I add the User-Agent header, it disappears:
Cache-Control: max-age=0
Connection: keep-alive
Content-Type: text/plain
Date: Fri, 02 Jun 2017 14:17:21 GMT
Etag: W/"59316a61-25a"
Expires: Fri, 02 Jun 2017 14:17:21 GMT
Last-Modified: Fri, 02 Jun 2017 13:38:41 GMT
Server: nginx
Transfer-Encoding: chunked
Vary: Accept-Encoding

What kind of magic is this? Maybe I misconfigured something? It seems that this is not the first time I turn on gzip, but I see this behavior for the first time.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question