I have reverse proxy like this:
server {
listen 8080;
location = /my-proxy {
proxy_pass https://somehost/v1
}
}
Now I would like to pass it to /v2 if HTTP request header x-version-toggle
is set to v2
, something like this:
server {
listen 8080;
location = /my-proxy {
if ($http-x-version-toggle == 'v2') {
proxy_pass https://somehost/v2
}
proxy_pass https://somehost/v1
}
}
What is the precise syntax to achieve this?