Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Yes, I know that there are a lot of other questions that seem exactly like this out there. I think I must've looked all of them. Twice. In desparation, I'm adding another in case my specific configuration is the issue. Bear with me.

First, the question: What do I need to do to get gzip compression to work?

I have an Ubuntu 12.04 server installed running nginx 1.1.19. Nginx was installed with the following packages:

nginx
nginx-common
nginx-full

The http block of my nginx.conf looks like this:

http {
  include /etc/nginx/mime.types;

  access_log /var/log/nginx/access.log;

  sendfile on;

  keepalive_timeout  65;
  tcp_nodelay        on;

  gzip  on;
  gzip_disable "msie6";

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

Both PageSpeed and YSlow are reporting that I need to enable compression. I can see that the request headers indicate Accept-Encoding:gzip,deflate,sdch, but the response headers do not have the corollary Content-Encoding header.

I've tried various other config values (gzip_vary on, gzip_http_version 1.0, etc.), but no joy.

As far as I know, I can only assume that nginx was compiled with compression support, but if there's any way to verify that, I'd love to know.

If anyone sees anything I'm missing or can suggest further debugging, please let me know. I'm no sysadmin and I'm new to Nginx so I've exhausted everything I can think of or have read.

Thanks.

share|improve this question
    
My first idea would be to check log files for any errors during startup. To check what modules nginx supports, you can run nginx -V. –  brain99 Aug 30 '12 at 15:37
    
Which file type are you checking header? –  quanta Aug 30 '12 at 15:43

1 Answer 1

up vote 4 down vote accepted

If nginx doesn't complaing about gzip on; being in your configuration file, then it's been compiled with the gzip module. By default, it only compresses text/html responses. You need to configure gzip_types if you want to compress anything else (css, js, etc).

share|improve this answer
    
It looks like this was the key. I can't believe that I didn't bump into a single resource that indicated that gzip_type values were required for anything other than html, but I sure don't remember seeing that. Thanks for your help. –  Rob Wilkerson Aug 30 '12 at 16:06
1  
@Rob Wilkerson I'd suggest in future to look at documentation first and SF second. wiki.nginx.org/HttpGzipModule is not that large and checking gzip_types would show you the default is text/html. –  Martin Fjordvald Aug 30 '12 at 17:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.