Sometimes you want to connect to a different set of upstream nodes from an NGINX load balancer.

When you’re creating load balancing configurations in NGINX, sometimes you are going to want to route traffic from a certain IP address to a different set of upstream nodes. This may be because you have a CI environment which uses the same load balancer (staging) or could be for other reasons.

Regardless, create your alternative upstream:

upstream defaultNodes {
	server;	# default nodes...

upstream alternativeNodes {
	server;	# new nodes...

Then in the server directive, add the condition (assuming the public IP you want to route is

location / {

	proxy_pass http://defaultNodes/;

	if ( $remote_addr ~* ) {
		proxy_pass http://alternativeNodes;