Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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.


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
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
@Rob Wilkerson I'd suggest in future to look at documentation first and SF second. is not that large and checking gzip_types would show you the default is text/html. – Martin Fjordvald Aug 30 '12 at 17:24
I have gzip_types text/css text/plain text/xml application/xml application/javascript application/x-javascript text/javascript application/json text/x-json image/gif image/jpeg image/png; and NGINX doesn't set Content-Encoding header. When I check nginx -V, it only has --with-http_gzip_static_module and no ngx_http_gzip_module. And no any complaints about gzip on; – Green Dec 9 '15 at 12:42

Your Answer


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.