Consider this configuration (given /foo
doesn't exist):
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/;
}
}
The response header X
is always 1
even when I navigate to /
. Why is this and how can I make variables propagate through try_files
?
if ($uri ~ ...) { set $x 0; }
but usingif
is discouraged. All configuration other than whether caching is enabled or not is the same.map
then.