Nginx – gzip compression doesn’t work in nginx reverse proxy setup

nginx

We have nginx in front of an Apache server in reverse proxy mode.

We initially had Apache compressing files using mod_deflate, however that proved to cause problems with some instances of Internet Explorer. My guess is that there was some strange handling of "vary" responses by nginx and it's proxy cache which triggered the IE problem.

We're now attempting to compress content using nginx itself, so we disabled mod_deflate in Apache, and added the following to the nginx server{} configuration

gzip             on;
gzip_proxied     any;
gzip_types       text/css text/plain text/xml application/xml application/javascript application/x-javascript text/javascript application/json text/x-json;
gzip_vary        on;
gzip_disable     "MSIE [1-6]\.";

This has no effect. The content is always served without gzip compression, as verified using Fiddler.

Things I have tried:

  1. Remove both the gzip_vary and gzip_disable options (the latter being
    implicated by some other questions on this site).
  2. Move the gzip
  3. settings into the location{} part of the server{} settings. Move the gzip settings before and after location{}

Does anybody have this kind of setup working?

OS: CentOS 2.6.18-274.17.1.el5, nginx version: 1.0.12

Best Answer

To answer my own question: The problem seemed to be that "nginx reload" didn't cause the setting to take effect. Issuing a full "nginx restart" fixed it.