Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

Re: Nginx X-Accel-Redirect stripping Content-Encoding header

$
0
0
Hello!

On Fri, Jun 28, 2013 at 06:21:08AM -0400, Danack wrote:

> I have Nginx setup to allow requests to be served with the X-Accel-Redirect
> header. This works fine for images, but I'm trying to get it to work for
> Javascript files that are already gzip'ed on the disk.
>
> It appears Nginx is stripping off the 'Content-Encoding: gzip' header. This
> makes the browser not unzip the content when it receives it, which obviously
> makes it not work.
>
> Is it possible to make Nginx preserve the Content-Encoding header to allow
> pre-gzipped content through X-Accel-Redirect? Or is there another way to
> allow this work?

Any headers from the original response (the one with X-Accel-Redirect)
might be preserved using the $upstream_http_* variables. Something
like this should work:

location /files/ {
internal;
add_header Content-Encoding $upstream_http_content_encoding;
}

This might not work well with nginx gzip filter though.

Better solution might be to just return X-Accel-Redirect to an
unrompressed file, and use gzip_static to serve precompressed
files if they are available and supported by a client, see
http://nginx.org/r/gzip_static.

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Viewing all articles
Browse latest Browse all 53287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>