I am trying to combine these 2 Nginx location definitions into 1
location /v1/login {
proxy_pass http://upstream/v1/login;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Authorization;
}
location /v1/logout {
proxy_pass http://upstream/v1/logout;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Authorization;
}
So I figured something like this should do the job
location ^~ /v1/(login|logout) {
rewrite ^/v1/(.*)$ /v1/$1 break;
proxy_pass http://upstream;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
But for the life of me I can't get it to work. What am I doing wrong here? I have tried every possible combination of rewrite regexes.