why nginx is not compressing reply from proxied server?
Maxim Dounin
mdounin at mdounin.ru
Tue May 11 21:23:17 UTC 2021
Hello!
On Tue, May 11, 2021 at 06:16:46PM +0300, Peter Volkov wrote:
> Err, After few hours of debugging, and writing email here, I've realised
> that I have `gzip off;` in http {} block of configuration. After enabling
> gzip in http block everything works fine. Is it correct behaviour that no
> warning is issued with such configuration?
The configuration specified in http{} block applies, unless you've
redefined the configuration in more specific scope, such as
server{} or location{}. That is, the following configuration
won't use gzip:
http {
gzip off;
server {
listen 80;
}
}
But the following will:
http {
gzip off;
server {
listen 80;
gzip on;
}
}
That's how it is expected to work.
If a configuration with "gzip off;" at the http level and "gzip on;"
at the server level doesn't work for you, but changing it to "gzip
on;" at the http level works, most likely this means that you are
looking at the wrong server{} block.
Note that the configuration you've provided listens on the port 80
(the default):
> > server {
> > gzip on;
> > gzip_comp_level 5;
> > gzip_http_version 1.0;
> > gzip_buffers 4 32k;
> > gzip_min_length 0;
> > gzip_types application/octet-stream;
> > gzip_proxied any;
> > gzip_vary on;
> >
> > proxy_buffering off;
> >
> > location / {
> > proxy_pass http://10.239.254.17:9102;
> > }
> > }
And you are testing port 9102, not 80:
> > curl -v IP:9202 -H 'Accept-Encoding: deflate, gzip' -o output
Most likely this means that you are testing against the wrong
server{} block, and that's why "gzip on;" at http{} level works
for you.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx
mailing list