Hello everyone,
In this blog, we are going to Configure Reverse Proxy i.e. Haproxy and update it's configuration file automatically on each time a new Managed node (Configured With Apache Webserver) join the inventory
Before we start we should know what is HAProxy?
What is HAProxy?
HAProxy is free, open-source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spread requests across multiple servers. It is written in C and has a reputation for being fast and efficient.
Let's get started...
My setup is something like this, I have configured 3 servers in my virtual machine, one is load balancer or Frontend and the other two are Backend Server 👇
Configure the Control node
Create an Inventory and add Frontend and Backend servers IP, username, and password.
Check the connectivity of servers using ping command
Now create Playbook
In this playbook, HAProxy is installed in Frontend that is in load balancer and in Backend webserver is configured and PHP file is uploaded for demo purpose.
HAProxy Configuration
Now run the playbook
- Now check-in Load Balancer HAProxy is installed or not
Here you can see it is installed successfully!!
Now let's check HAProxy is working or not
For this demo, I have created a PHP code that will open in the browser and will show IP address, from this we can clearly see in the backend how traffic is managed or how the load is distributed.
- from my Load Balancer or Frontend Ip i will on PHP code in the browser.
Here you can see PHP code works fine and notice the IP Address, this IP is of one of the Backend server.
- Now let's see what happens when I will refresh the page or when traffic comes
Here you can see the IP of another Backend server. That's how we can manage load in web server.
That's how we can configure HAProxy using Ansible..
Thank you!!❄
Top comments (0)