How to grab a value from a request

Francis Daly francis at daoine.org
Mon Oct 2 23:43:24 UTC 2017


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) with named regex captures.

In this specific case:

> Request: https://api.domain.com/[resource]/v2/
> Upstream: https://app.domain.com/api/[resource]/v2/

  location / { proxy_pass https://app.domain.com/api/; }

might do exactly what you want.

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list