How Can Nginx Be an HTTP Load Balancer for Apache Web Servers?

Problem scenario
You have an Nginx server that you want to be a traffic distributor to Apache web servers.   What has to be done to configure Nginx's HTTP load balancing function to relay inbound connection requests to Apache web servers?

Solution
Nothing special has to be done for the web servers.  Nginx can be a reverse proxy to either Nginx web servers or Apache web servers.  The "upstream backend {}" block in the  file /etc/nginx/conf.d/default.conf in Nginx's distributor instance merely has to have stanzas  like these:

upstream backend {
server apache.web.server.com;
}

where the apache.web.server.com is the fully qualified domain name of the web server or the IP address of the web server.  The web server can be either Nginx or Apache.  Nothing special needs to be done if the web server is Apache. 

FFR
If you want to need to troubleshoot problems with your Nginx load balancer, see this link.

Leave a comment

Your email address will not be published. Required fields are marked *