Is it possible to use private ip address instead of domain for nginx load balancer setup?

June 17, 2018 175 views
Nginx Load Balancing Ubuntu 16.04

Hi, I try to create one nginx load balancer and 1 apache php backend server by refer to
nginx load balancing.

I want to limit all public access to the backend server. Only load balancer can accept public access (like http or https). Then I want my load balancer pass the query to the backend server via private network.

So I setup both servers with private network. I successfully query the nginx welcome page from load balancer. I also successfully get the apache welcome page from backend before I restrict public access with digitalocean firewall.

Then I setup the upstream directive for nginx like what it showed from the article except I use the backend server's Private IP instead of a domain name in config file like:

upstream backend{
server; <== in the article this is
server {
location / {
proxy_pass http://backend;

At this time I assume I should see the apache page when I visit the load balancer public IP but it did not show up. I wonder if this is because of the backend private IP which I place in the nginx config file? Is it possible to use ip instead of domain to setup nginx load balancer? Thanks

1 Answer

Yes you should be able to use the Private IP address to communicate between droplets as this is the intended purpose and providing they reside in the same datacenter.

You may need to ensure that the firewall does not block the Private IP address as well or if you have something like UFW running to ensure you correctly set the rules.

Have another answer? Share your knowledge.