Craete HAProxy load balancer for two Nginx web servers using Docker-Compose and Bash scripting
Creates HAProxy load balancer for two Nginx web servers using Docker containers and Bash script. The script will create and configure 3 servers, one load balancer, and two Nginx web servers. HAProxy will be installed on on a single server and then install Nginx web server on the other 2 servers, and HAProxy will act as a load balancer for the Nginx web servers. All of the 3 servers will be containerized using Dockerfile and Docker-Compose.
HAProxy will run in Layer 4 TCP mode, and will forward the RAW TCP packets from the client to the application servers, all the requests go to HAProxy container, and HAProxy will call either the first Nginx or the second one.
cd nginx-haproxy-docker
chmod a+x script.sh
./script.sh
Test the load balancer by executing some random curl commands on the HAProxy IP to check the response from both web servers
curl 172.16.0.2
Benchmark the web servers by sending a punch of requests directly:
ab -n 3000 -c 20 http://172.16.0.2/