NGINX gzip_static不起作用

我在nginx上有以下conf:

location ~* ^/assets/ { add_header Access-Control-Allow-Headers content-type; add_header Access-Control-Allow-Origin *; add_header Cache-Control "public, max-age=31536000"; proxy_pass http://nas-mydomain.com; proxy_next_upstream http_500 timeout; gzip_http_version 1.0; gzip_static always; gzip_vary on; etag on; } 

我的目标是提供gzipped格式的文件夹中的静态内容。

我当然创build了如下的文件:

 test.js test.js.gz 

我可以达到每个文件和所有标题正确设置以及etags。 但是,gzip检索不起作用。 例如,我testing它是这样的:

 curl -H "Accept-Encoding: gzip" http://domain.com/assets/test.js | gunzip ## Cutted useless output gunzip: unknown compression format 

所以我猜这是行不通的。 我也试着听:

 strace -p pid1 -p pid2 -p pid3.... 2>&1 | grep gz 

没有运气。

而且,当然,如果我这样做:

 curl http://domain.com/assets/test.js.gz | gunzip ## Cutted useless output 

一切正常。

任何提示?

 nginx -v = nginx version: nginx/1.8.0 #--with-http_gunzip_module --with-http_gzip_static_module are present 

你正在做proxy_pass,这就是问题所在。 从服务器本身提供这些文件,即使用“root / some / path”指令,一切都应该工作。