nginx upstream source ip address

Francis Daly francis at daoine.org
Sun Nov 13 20:18:08 UTC 2016


On Sat, Nov 12, 2016 at 03:25:49AM +0000, Michael Power wrote:

Hi there,

> I have an nginx web server with two ip addresses.  I want to connect to two upstream servers, where one upstream is configured to use one of the ip addresses and the other upstream is configured to use the second ip address.
> 

I think that you are asking about setting the source address that nginx
should use when it is making a proxy_pass connection to an upstream.

If so: in general, nginx leaves that to the OS to decide. So if you can
set your local routing table such that any traffic to upstream1 comes
from ip1 and traffic to upstream2 comes from ip2, then nginx will Just
Work (as will anything else on your nginx-serving machine).

If you won't do that, then if you have the case where proxy_pass in one
location goes to upstream1 and proxy_pass in another location goes to
upstream2, then proxy_bind (http://nginx.org/r/proxy_bind) can do what
you want.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list