0

I'd like to catch a part of the server_name to route an old domain to a new one like:

server {
    server_name   "~^(?<domain>)\.v1.+$";

    location / {
        proxy_pass       https://$domain.v2.com/;
        proxy_set_header Host            $domain.v2.com;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
}

The problem is that the domain variable is empty an nginx tries to resolve .v2.com. I'd like to catch everything from the server_name which is before .v1 and write it to the proxy_pass.

McDizzy
  • 189
  • 11

0 Answers0