Re: How to grab a value from a request

2017-10-04 Thread Reinis Rozitis
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

Re: How to grab a value from a request

2017-10-04 Thread Francis Daly
On Tue, Oct 03, 2017 at 11:29:44AM -0400, halfpastjohn wrote: Hi there, > I'm sorry i don't quite follow. How is your example using the map directive? It isn't. If you want to pick pieces from the request, you can use "map". However, what you have described so far as your use case does not nee

Re: How to grab a value from a request

2017-10-03 Thread halfpastjohn
Would this work? location ~ ^/users/v2/ { proxy_pass http://app.domain.com/api/$1/v2; } Would $1 resolve as users or does it need to be inside ()? Posted at Nginx Forum: https://forum.nginx.org/read.php?2,276652,276664#msg-276664 ___ nginx mailing li

Re: How to grab a value from a request

2017-10-03 Thread Reinis Rozitis
I'm sorry i don't quite follow. How is your example using the map directive? Just for clarity, here is what I'm trying to do. location /[resource]/v2/ { proxy_pass http://app.domain.com/api/[resource]/v2; } Well in general it's something like: location ~ ^/(.*)/v2/ { proxy_pass

Re: How to grab a value from a request

2017-10-03 Thread halfpastjohn
I'm sorry i don't quite follow. How is your example using the map directive? Just for clarity, here is what I'm trying to do. location /[resource]/v2/ { proxy_pass http://app.domain.com/api/[resource]/v2; } In fact, the location bit will be hardcoded with the actual resource, I just need the

Re: How to grab a value from a request

2017-10-02 Thread Francis Daly
On Mon, Oct 02, 2017 at 06:23:37PM -0400, halfpastjohn wrote: Hi there, > I'm setting up nginx as a proxy router for various APIs. How can I take a > specific value form the incoming request and dynamically populate it into > the upstream? In general, you can use map (http://nginx.org/r/map) wit

How to grab a value from a request

2017-10-02 Thread halfpastjohn
I'm setting up nginx as a proxy router for various APIs. How can I take a specific value form the incoming request and dynamically populate it into the upstream? Request: https://api.domain.com/[resource]/v2/ Upstream: https://app.domain.com/api/[resource]/v2/ I this case, I want to take [resourc