Using if statements in a location block with set

justin nginx-forum at nginx.us
Fri Sep 6 23:42:39 UTC 2013


Is the following going to work as expected:

location /v1/users {
        rewrite       ^/users/(.*)/accounts$   /v1/users/$1/accounts break;

        if ($server_name = 'js.mydomain.com') {
            set $backend  "api.mydomain.com";
        }

        if ($server_name = 'js-s.mydomain.com') {
            set $backend  "api-s.mydomain.com";
        }

        proxy_pass     https://$backend;
    }

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,242643,242643#msg-242643



More information about the nginx mailing list