0

I'm tring to get the URI parts to then pass it to the proxy_pass url. But I don't know about regex to do this.

I need to get the first and last URI into a variables to pass it on the proxy_pass like this:

https://example.com/user/port

to

proxy_pass http://user.example.com:$port

1 Answers1

0

You can use regex.

Nginx config Example:

location ~ ^/(\w+)/(\d+)$ {
  set $user $1;
  set $port $2;
  proxy_pass http://${user}.example.com:$port;
}
Hawshemi
  • 302
  • 5