我有一个用gzip_static模块构build的nginx实例
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/
我的configuration文件有选项打开:
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; } } }
我有一个gzipped版本的文件,我正在寻找与未压缩的文件相同的目录,并且都有相同的时间戳。
-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
当我提出请求时,我validation了Accept-Encoding:gzip,deflate,sdch头正在发送。 该请求也是HTTP 1.1。
我可以通过strace看到文件正在被打开,但是由于压缩文件的内容与未压缩文件的内容不同,我知道它没有返回.gz版本。
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
我觉得我在这里错过了一些基本的东西。 我已经阅读了关于这个主题的所有内容,但是我认为我已经完成了自己的能力。
有人可以帮助我了解我出了什么问题,或者我可以做些什么来进一步解决这个问题?
谢谢。
原来我和目标机器之间有一个WAN优化器。 这个优化器在请求到达nginx之前删除了Accept-Encoding头(如logging所示)。
如果有其他人来自search,这里是我如何login标题:
log_format withheader '[$time_local] "$request" $status [$http_accept_encoding]'; access_log logs/withheader.log withheader;
在nginx中,可以使用$http_来logging标题,然后使用空格和连字符转换为下划线来$http_小写字母的名称。