In this post, we will cover the following points
- What is Nginx?
- Install Nginx
- Configuring Nginx as a load balancer
What is Nginx?
NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more.
Once done start serevr using below command
If all goes well, in a browser hit http://localhost You should see something like this
Configuring Nginx as a load balancer
Please note I am running this setup on my local machine so using localhost. In general, we will replace localhost with some IP.
- Edit nginx.conf and add following lines in http section
The whole block looks like this
- We need to add proxy URL as customurl which was added in nginx.conf
- Make sure URL customurl is configured with DNS. Eg I have added URL in /etc/hosts to map to IP
- Restart your Nginx server.
- Now in a browser try http//:customurl .
- It should redirect to any one server which we configured.
- Now, shut down one of the servers. Hit refresh
- The browser will still redirect to your server. That’s Load balancing in Action.