problem w/ gzip when hiding Content-Type header from upstream server

bavery nginx-forum at
Tue Jul 14 12:07:47 MSD 2009

I have the exact situation described in the wiki for the proxy_hide_header command, where my upstream server sends my JS & CSS files with the wrong Content-Type header.  The file is currently being sent with a text/html content-type from the upstream server, but I am experiencing some occasional issues with browsers not rendering the CSS and suspect it may possibly be due to not having the correct content-type header, since I have read that this can sometimes cause the problems I am seeing.

    location /combined.css {
        proxy_pass http://$proxyforwardto/v/vspfiles/assets/combined.css.asp;
        proxy_hide_header Content-Type;

I have the following line in my config file for specifying which file types gzip should compress.
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

My problem seems to be that once the Content-Type header is hidden with proxy_hide_header, nginx does not seem to be attempting to determine the correct type itself.  My CSS & JS files are simply passed on uncompressed, with no content-type header. Mime-types are configured correctly in my nginx config, but it doesn't seem to make a difference for these particular files.  I have tried using proxy_set_header to specifically set the content-type header as text/css, but nginx seems to completely ignore this and continues sending the file through without changing the content-type header.

Is there something I am missing here? How can I get nginx to recognize that the .css & .js files it is pulling from the upstream server should still be compressed even though the Content-Type header is being hidden?  I am running nginx version 0.8.0.


Posted at Nginx Forum:,4037,4037#msg-4037

More information about the nginx mailing list