Change target host in proxy_pass

Lucas Rolff lucas at
Fri Mar 17 11:47:21 UTC 2017

You can proxy_set_header Host – that should override whatever is defined in proxy_pass

From: nginx <nginx-bounces at<mailto:nginx-bounces at>> on behalf of Tomasz Kapek <kapekto1 at<mailto:kapekto1 at>>
Reply-To: "nginx at<mailto:nginx at>" <nginx at<mailto:nginx at>>
Date: Friday, 17 March 2017 at 12.12
To: "nginx at<mailto:nginx at>" <nginx at<mailto:nginx at>>
Subject: Change target host in proxy_pass

I have NGINX acting as reverse proxy and I would like to achieve something like this:

When I get a request like this GET it should be converted to:
GET so such directive will do the job:

problem is that I want to convert host part automatically (regex) basing on incoming requests to NGINX  - app1.mydomain are not fixed they are changing very often.
Is it possible? Can anyone get a clue how proxy_pass statement should look like?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list