Welcome! Log In Create A New Profile

Advanced

Change target host in proxy_pass

Posted by Tomasz Kapek 
Tomasz Kapek
Change target host in proxy_pass
March 17, 2017 12:20PM
Hello,
I have NGINX acting as reverse proxy and I would like to achieve something
like this:

When I get a request like this GET http://app1.mydomain.aa.com/aaa/bbb it
should be converted to:
GET http://app1.mydomain.bb.com/aaa/bbb so such directive will do the job:

proxy_pass http://app1.mydomain.bb.com;
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?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Lucas Rolff
Re: Change target host in proxy_pass
March 17, 2017 12:50PM
You can proxy_set_header Host – that should override whatever is defined in proxy_pass

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

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

When I get a request like this GET http://app1.mydomain.aa.com/aaa/bbb it should be converted to:
GET http://app1.mydomain.bb.com/aaa/bbb so such directive will do the job:

proxy_pass http://app1.mydomain.bb.com;
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?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login