我正在使用nginxcaching来自上游apache服务器的请求,但是我想要从apache一直提取几块内部。 我希望ssi可以做到这一点,但是SSI标签不经过预处理就输出给用户。
location ~* ^.+\.html$ { proxy_pass http://localhost:9999; proxy_cache_key "$prime$scheme$host$request_uri"; ssi on; ssi_silent_errors off; log_subrequest on; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Country $country_code; proxy_cache my-cache; proxy_cache_bypass $http_x_refresh_cache; proxy_cache_valid 200 302 30d; proxy_cache_valid 404 10m; proxy_cache_valid any 1m; }
这是相关的nginx conf。
proxy_cache_key "$prime$scheme$host$request_uri";
这一行在相同的键(用户键入的URI)下caching页面的所有单独部分,因此页面的不同部分相互覆盖,然后只返回写入的最后一个部分。 您希望使用$uri而不是$request_uri ,以便每个页面的每个部分都以自己的个人名称进行caching。
确保http:// localhost:9999不压缩输出。 通过添加简单
proxy_set_header Accept-Encoding "";
请参阅: https : //stackoverflow.com/questions/24680989/with-nginx-how-do-i-run-ssi-on-a-page-returned-from-another-server