1

So I installed and configured Nginx 0.7.62 on a new Slicehost Ubuntu 9.10 slice.

All seems to work fine with the server, except that gzip isn't working for one reason or another. I made sure that it's setting were correct in /etc/nginx/nginx.conf:

user www-data;
worker_processes 3;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
    # multi_accept on;
}

http {
    include /etc/nginx/mime.types;
    access_log /var/log/nginx/access.log;

    sendfile on;
    #tcp_nopush on;

    keepalive_timeout 2;
    tcp_nodelay on;

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

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

This normally wouldn't be a big deal, but gzip support could save considerable bandwidth for my site. Does anyone have any ideas of what to check, or has anyone else run into this problem?

1
  • 1
    How were you testing that the compression was working? If you are using one of the many public checkers it could be that their checker pretends to be IE6-pre-SP2 so your gzip_disable directives were firing and turning the feature off when the checker made requests. May 27, 2010 at 11:44

6 Answers 6

3

Thanks for everyone's help. I managed to figure it out... (bizarre, still not sure why)

In Ubuntu 9.10, Nginx 0.7.62:

  1. I first tried using gzip_disable "MSIE [1-6]."; #still broken
  2. I then switched it to gzip_disable "msie6"; #still broken
  3. I commented out the gzip_disabled line altogether #fixes the problem

Hope this saves someone else some time.

2
  • removing gzip_disabled indeed solved my problem. Thanks.
    – Tiago
    Mar 26, 2011 at 21:19
  • This worked for me too. What's odd is that it was actually working for some resources with gzip_disable. But when I commented out that line, it started working for application/x-javascript resources.
    – mahemoff
    Aug 22, 2011 at 17:23
2

Passenger now compiles the gzip module upon installing nginx. It's much easier to go this route nowadays

1

Try putting this into nginx.conf:

gzip on;
gzip_vary on;
gzip_min_length  1100;
gzip_comp_level 1;
gzip_http_version 1.0;
gzip_proxied any;
gzip_disable "msie6";
gzip_types  text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
0

at first here is the description to build nginx on linux

http://wiki.nginx.org/NginxInstallOptions

Can you verify that your build support gzip?

  --with-http_gzip_static_module 

Or you didn't build with:

--without-http_gzip_module - Disable ngx_http_gzip_module. Requires zlib if enabled. 

How can you see that the gzip is not working btw.?

1
0

All the suggestions from l1x were checked off. Anyone have some ideas? The package was installed using apt-get (so it was pre-compiled)...

0

Very strange as I just removed the gzip_disable line to resolve my issue. Maybe this is a bug. Worked fine in a previous version of nginx that I was running...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.