One NGINX server to 2 backend servers

Francis Daly francis at daoine.org
Sat Mar 4 08:43:59 UTC 2017


On Fri, Feb 24, 2017 at 06:17:51AM -0500, p0lak wrote:

Hi there,

> I want to define this behavior
> 
> NGINX Server (Public IP) >>> listening on port 80 >>> redirect to a LAN
> Server on port 80 (http://mylocalserver/virtualhost1)
> NGINX Server (Public IP) >>> listening on port 81 >>> redirect to a LAN
> Server on port 80 (http://mylocalserver/virtualhost2)

Some of the terms you use here do have specific meanings in a http
context, and it may or may not be the case that you mean the same thing.

For clarification:

if you access your two internal web areas directly, do you access
things like

http://servername/directory1/ and http://servername/directory2/

or

http://servername1/ and http://servername2/

?

(You do say the first; but the term "virtual host" would usually refer
to the second. And the nginx config will differ depending on which it is.)

If it is the first, then it is probably easier for you just to have
nginx listening on public port 80, and accept requests for /directory1/
and /directory2/ and proxy_pass them as-is to the internal server.

If instead you want one nginx listener on port 80 and another on port 81,
then you will possibly have to make sure that the internal web areas
are happy with being proxy_pass'ed like that -- they may need extra
configuration to know the public url that refers to them if they create
absolute urls within the html they return, for example.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list