Madness: Breaking IF clause LOCATION
With nginx.conf
including the following
location /beta/ {
proxy_pass http://otherhost/;
}
then both of the following search processes work:
-
curl -H 'User-Agent: Mozilla' http://localhost/beta/admin.html
-
curl -H 'User-Agent: iPhone' http://localhost/beta/admin.html
They both extract http://otherhost/admin.html
When I change nginx.conf to read:
location /beta/ {
if ($http_user_agent ~ iPhone ) {
}
proxy_pass http://otherhost/;
}
Then it curl -H 'User-Agent: Mozilla' http://localhost/beta/admin.html
keeps working but
curl -H 'User-Agent: iPhone' http://localhost/beta/admin.html
gives 404 and otherhost complains that it doesn't have a file named beta/admin.html
. This happens if if
empty or not.
AND?
source to share
You get a little known issue: If this is evil in nginx , then if
-blocks inside location
-blocks should be avoided if at all possible (link explains why and how)
source to share