How can I add header conditionally in nginx(1.4.6 ubuntu) configuration?
At first I tried like this.
location / {
add_header X-TEST-0 always-0;
set $true 1;
if ($true) {
add_header X-TEST-1 only-true;
}
add_header X-TEST-2 always-2;
}
Although I expected my nginx set all header(X-TEST-0,1,2), it added header only X-TEST-1.
Next I tried like this.
location / {
add_header X-TEST-0 always-0;
##set $true 1;
##if ($true) {
## add_header X-TEST-1 only-true;
##}
add_header X-TEST-2 always-2;
}
My nginx added header X-TEST-1 and X-TEST-2 as I expected.
My quastions are...
How can I add header conditionally?
Why does nginx add only X-TEST-1 with my first example above?
Thanks in advance!
setinsideif. Or usemapdirective.mapas described in serverfault.com/a/598106/119913