考虑这个configuration(给/foo不存在):
server { set $x 1; location = / { set $x 0; try_files /foo @l; } location / { try_files /foo @l; } location @l { set_header X $x; proxy_pass http://localhost:1000/; } }
即使我导航到/时,响应标题X始终为1 。 为什么是这样的,我怎样才能让variables通过try_files传播?
根据你的评论,正确的做法是通过使用fastcgi_no_cache指令和地图结合。 一个例子来显示它的样子:
map $uri $cache { default "1"; "~^/myuri" "0"; } server { ... location / { fastcgi_no_cache $cache; fastcgi_pass ... } }