Nginx Reverse Proxy Gzip to Client

Solution 1:

You can add the gzip_proxied any; directive to your conf.

edit:

My test :
I set up a simple HTTP Server (not able to gzip by itself) on my machine (192.168.122.1) with python -m http.server 8080. When I request it I get :

[pat@morbier ~]$ curl -I -H 'Accept-Encoding: gzip,deflate' http://192.168.122.1:8080/
HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.5.0
Date: Thu, 22 Oct 2015 17:41:39 GMT
Content-type: text/html; charset=utf-8
Content-Length: 1197

I set up a proxy with nginx (192.168.122.224)

gzip_min_length     1000;
gzip_buffers        4 8k;
gzip_http_version   1.0;
gzip_disable        "msie6";
gzip_types          text/plain text/css;
gzip_vary           on;

location / {
    proxy_set_header x-real-IP $remote_addr;
    proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
    proxy_set_header host $host;
    proxy_pass http://192.168.122.1:8080;
}

When I request the same thing with the proxy I get

[pat@morbier ~]$ curl -I -H 'Accept-Encoding: gzip,deflate http://192.168.122.224/
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Thu, 22 Oct 2015 17:46:08 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1197
Connection: keep-alive

Then I add to the proxy conf

gzip on;
gzip_proxied any;

And I get

[pat@morbier ~]$ curl -I -H 'Accept-Encoding: gzip,deflate' http://192.168.122.224/
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Thu, 22 Oct 2015 17:47:54 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Content-Encoding: gzip

You can also see it if you curl without -I (so getting the whole page), in my case it turns to be some binary displayed on the terminal, reinforcing the fact that it's compressed. When I curl the regular website that is not gzipping I get the content of the webpage (HTML).

edit2:
It actually works only with your options enabled, it seems it's no need to have gzip_proxied.
Ah you're requesting without passing the 'Accept-Encoding: gzip,deflate' header (I guess you're using telnet). It won't work in that case because you don't say to the server that you can process gzip encoded binary.
Try with curl please.