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.

I have an nginx instance built with the gzip_static module

nginx version: nginx/1.2.6
built by gcc 3.4.6 20060404 (Red Hat 3.4.6-11)
TLS SNI support disabled
configure arguments: --prefix=/home/nginx --user=nginx --group=nginx 
--without-http_autoindex_module --without-http_empty_gif_module 
--without-http_scgi_module --with-http_ssl_module 
--with-http_gzip_static_module --with-pcre=./library/pcre-8.32/ 
--with-zlib=./library/zlib-1.2.7/

My configuration file has the option turned on:

http {
    include mime.types;
    default_type application/octet-stream;

    gzip off;
    gzip_static on;
    gzip_vary on;

    server {
        listen 8080;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}

And I have a gzipped version of the file I'm looking to request in the same directory as the uncompressed file and both have the same timestamp.

-rw-r--r--  1 root root   123 2013-03-28 16:42:46.000000000 ../html/test.html
-rw-r--r--  1 root root   121 2013-03-28 16:42:46.000000000 ../html/test.html.gz

When I make a request I verified the Accept-Encoding:gzip,deflate,sdch header is being sent. The request is also HTTP 1.1.

I can see via strace that the file is being opened, but because the content of the compressed file is different from the uncompressed, I know it's not returning the .gz version.

recv(3, "GET /test.html HTTP/1.1\r\nHost: x"..., 1024, 0) = 98
open("/home/nginx/html/test.html.gz", O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 4
open("/home/nginx/html/test.html", O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 7

I feel like I'm missing something fundamental here. I've read all I could find about the subject, but I think I'm at the end of my abilities.

Could someone please help me to understand where I've gone wrong or what I can do to further troubleshoot this problem?

Thank you.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Turns out there was a WAN optimizer between me and the target machine. This optimizer removed the Accept-Encoding header (as evidenced by logging) before the request reached nginx.

In case there are others coming here from a search, here is how I logged the header:

log_format withheader '[$time_local] "$request" $status [$http_accept_encoding]';
access_log logs/withheader.log withheader;

In nginx, you can log headers by using $http_ and then the header name, lower case, with spaces and hyphens converted to underscores.

share|improve this answer

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.