Use sub-url to identify the different server

Francis Daly francis at daoine.org
Thu Jan 10 23:48:05 UTC 2019


On Thu, Jan 10, 2019 at 02:54:14AM -0500, nevereturn01 wrote:

Hi there,

> I have 2 internal web hosts & 1 dedicate Nginx as reverse proxy, eg 10.1.1.1
> & 10.1.1.2
> 
> Now, I need to access the different hosts via sub-url. eg:
> 
> 1. https://www.domain.com/site1 -----> https://10.1.1.1/
> https://www.domain.com/site1/ui -----> https://10.1.1.1/ui/
> 2. https://www.domain.com/site2 -----> https://10.1.1.2/
> https://www.domain.com/site2/ui -----> https://10.1.1.2/ui/

If you have the freedom to change the internal web hosts, such that
(for example) the 10.1.1.1 content is all locally below the url
//10.1.1.1/site1/ instead of //10.1.1.1/, then you will probably find
it much easier to reverse-proxy them.

  location /site1 { proxy_pass https://10.1.1.1; }
  location /site2 { proxy_pass https://10.1.1.2; }

is possibly all you would need in that case.

If you can't do that, then the start of what you will need will be
more like

  location /site1/ { proxy_pass https://10.1.1.1/; }
  location /site2/ { proxy_pass https://10.1.1.2/; }

but you will have to take care that anything that is returned to the
client that will be interpreted as a url, will be interpreted the way
you want it to be. If the internal servers do not make that easy, it
will probably not be easy for you.

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list