Opened 7 years ago
Closed 7 years ago
Last modified 7 years ago
#965 closed defect (invalid)
gzip_static isn't working with proxy_pass
|Reported by:||Owned by:|
|uname -a:||MINGW32_NT-6.1 S34D00D 1.0.18(0.48/3/2) 2012-11-21 22:34 i686 Msys|
nginx version: nginx/1.9.15
built by cl 16.00.30319.01 for 80x86
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-8.38 --with-zlib=objs.msvc8/lib/zlib-1.2.8 --with-select_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-openssl=objs.msvc8/lib/openssl-1.0.2g --with-openssl-opt=no-asm --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-ipv6
I've been trying to get gzip_static working for a few days now. It appears that it only works for location's configured for direct serving of content (i.e. with a root) versus location's with a proxy_pass.
For instance, here's a portion of my nginx.conf file:
I have both a boot.js file and a boot.js.gz version of the same file under C:/WS/application/dist/gzipped.
- Requesting boot.js with the "Accept-Encoding: gzip" header and BOTH the ROOT_LOCATION and the GZIPPED_ABSOLUTE sections of the config un-commented results in the compressed boot.js.gz file being returned. This can be verified by checking the "Content-Length" header against the size of boot.js.gz.
- Requesting boot.js with the "Accept-Encoding: gzip" header and BOTH the ROOT_LOCATION and the GZIPPED_PROXIED sections of the config un-commented results in the un-compressed boot.js file being returned. This can be verified by checking the "Content-Encoding" header and seeing that the response was not gzipped as well as checking the "Content-Length" header against the size of boot.js.
List item 3 is where my problem and I believe a bug lies. I've verified that the version of nginx that I'm running was compiled with the --with-http_gzip_static_module option. Additionally, I've enabled writing to the error_log at the debug level. I see entries related to http static show up with the GZIPPED_ABSOLUTE section enabled, but not when I have the GZIPPED_PROXIED section enabled.
Change History (6)
comment:1 by , 7 years ago
|Status:||new → closed|
comment:2 by , 7 years ago
|Status:||closed → reopened|
Unfortunately, including gzip_http_version with either a value of 1.0 or 1.1 doesn't affect the outcome at all.
comment:3 by , 7 years ago
|Status:||reopened → closed|
Well, it looks like I incorrectly understood your problem. You are trying to use
proxy_pass in the same location, and this isn't expected to work either. Documentation says:
The ngx_http_gzip_static_module module allows sending precompressed files with the “.gz” filename extension instead of regular files.
gzip_static is only expected to work when nginx is about to return regular files. It's not expected to do anything when all requests are proxied to an upstream server as happens with
proxy_pass. If you are using
proxy_pass, you have to the
gzip_static on the upstream server, where the file itself is returned (and on this upstream server you'll have to configure various
gzip_* directive correctly as well, including
As previously suggested, please use mailng lists if you have additional questions.
comment:4 by , 7 years ago
Thanks for the slight clarification. Why then would you ever use gzip_proxied with gzip_static?
follow-up: 6 comment:5 by , 7 years ago
gzip_proxied is not about
proxy_pass, but about requests which was got by nginx from other proxy servers (as indicated by
Via header). In particular, it's unsafe to return gzipped content to proxy servers when using HTTP/1.0 or not using
Vary with HTTP/1.1.
comment:6 by , 7 years ago
Thanks so much!
Most likely, your problem is gzip_http_version.
If you have additional questions, please use mailng lists instead.