How to grab a value from a request

Reinis Rozitis r at roze.lv
Wed Oct 4 15:51:46 UTC 2017


> Would this work?
>
> location ~ ^/users/v2/ {
> proxy_pass http://app.domain.com/api/$1/v2;
> }

No.

> Would $1 resolve as users or does it need to be inside ()?

For capturing (PCRE) a block into variable you need ().

You can also use named variables if the pattern/configuration becomes more 
complex ( for example 
http://nginx.org/en/docs/http/server_names.html#regex_names )

rr 



More information about the nginx mailing list