Hi,
I’ve run into a behavioral difference between different versions of
nginx, but I’m not sure which behavior is expected…
I need to proxy a request for a dynamically-assembled javascript file
to a set of app servers, but want to serve static js files directly
from nginx. I want to compress both proxied and unproxied js files.
The config below works, but doesn’t return a compressed file for the
proxied request in all environments. Unproxied javascript requests
are compressed in all cases.
nginx-0.5.20 on FreeBSD-6.2:
returns compressed files for all /js/ paths, including proxied
nginx-0.5.30 on Solaris 10:
returns compressed files for local /js/ paths, but
returns UNcompressed files for all upstream proxied /js/ paths
nginx-0.5.35 on Solaris 10:
(same as nginx-0.5.30 on Solaris 10)
I couldn’t find anything in the 0.5.20 - 0.5.30 release notes that
looked like a relevant bugfix or intentional behavior change.
I realize the environment diffs are substantial, but I’m also not
sure from the docs whether this should work. gzip_proxied
seems to control a conditional on the headers of the UA request,
and not be relevant to the gzip-or-not decision for the results
of upstream requests before returning to the UA. If it hadn’t
worked in 0.5.20 either, I’d assume that was the whole story.
The best answer might be “Hmm, weird, but you should just cache
the first request to /js/all.js and let nginx treat it as local
thereafter anyway”. Fair enough, but it adds some complexity
elsewhere that I’d like to avoid for now.
Here are the relevant bits of the config file:
handle static files directly
location ~ ^/(js|css|themes)/
{
root /path/to/docroot
gzip_types text/javascript text/css text/plain text/js
application/x-javascript application/javascript;
gzip_proxied any;
if ( $uri ~ ^/(js|css)/ ) { gzip on; }
force proxy for all.js, as it is ephemeral
if ( $uri = “/js/all.js” )
{ proxy_pass http://appservers; break; }
}
Thank you for any insights!
Andrew