Nginx X-Accel-Redirect stripping Content-Encoding header

Danack nginx-forum at
Fri Jun 28 12:29:42 UTC 2013

> Something like this should work:
>     location /files/ {
>         internal;
>         add_header Content-Encoding $upstream_http_content_encoding;
>     }

Thanks yep that worked.

> This might not work well with nginx gzip filter though.

And yes, I had to turn gzip off for the internal location used for
x-accel-redirect, otherwise it was setting the Content-Encoding header

> Better solution might be to just return X-Accel-Redirect to an 
> uncompressed file, and use gzip_static to serve precompressed 
> files if they are available and supported by a client, see 
Thanks for the tip.


Posted at Nginx Forum:,240406,240410#msg-240410

More information about the nginx mailing list