- nginx-webserver1: An Ubuntu VM running in nginx webserver.
- nginx-webserver2: An Ubuntu VM running in nginx webserver.
- haproxy: HA proxy points to 2 these web servers.
- Docker + Docker Compose
- Option-1: Build and run in background (Recommend)
cd devops-basics/topics/haproxy/basic/
docker-compose up --build -d
# To stop and remove contaienr, run:
docker compose down
- Option-2: Run and verbose the logs
cd devops-basics/topics/haproxy/basic/
docker-compose up --build
# To stop, press 'Ctrl + C'
-
Access the HA Proxy at http://localhost:6081 (You can replace 6081 by the port work on your machine!)
-
Refresh the page multiple time and you would see that the HA Proxy route to
nginx-webserver1
andnginx-webserver2
in Round Robin mode. -
Now try to stop the
nginx-webserver1
and refresh the page http://localhost:6081, it will check and only route tonginx-webserver2
docker stop nginx-webserver1