🔰HAProxy (Load Balancer) Configuration using Ansible on AWS🔰

An Introduction to HAProxy :

HAProxy, which stands for High Availability Proxy, is a popular open source software TCP/HTTP Load Balancer and proxying solution which can be run on Linux, Solaris, and FreeBSD. Its most common use is to improve the performance and reliability of a server environment by distributing the workload across multiple servers (e.g. web, application, database). It is used in many high-profile environments, including: GitHub, Imgur, Instagram, and Twitter.
HAProxy (Load Balancer) Architecture :

ARTH — Task 12 👨💻
Task Description 📃
Use Ansible playbook to Configure Reverse Proxy i.e. Haproxy and update it’s configuration file automatically on each time new Managed node (Configured With Apache Webserver) join the inventory on AWS.
👉🏻Lets get started…😃
🌟Controller Node🌟
My Controller Node IP 172.31.43.34 on which ansible is installed.
Let’s check its version :

🔹Inventory file : Here we put instance IP to which we want to configure as a Load Balancer and backend server.

✔Configuration file of ansible :
# vim /etc/ansible/ansible.cfg

🔹Now let’s check the connectivity :

🌟In Ansible Playbook :
🔹For configuring Load Balancer :

🔹For configuring Backend Server as a apache httpd webserver & hosting a webpage:

🔹HAProxy Configuration file :

🔹Now let’s run our playbook :
# ansible-playbook lb.yml

Done!!
🌟Managed/Target Nodes🌟
Now checking our managed nodes
🔶Load Balancer IP 172.31.39.218🔶

🔹Configuration file of HAProxy updated dynamically

🔶Backend Server IP 172.31.6.86🔶

🔹Let’s check our webpage from the browser :

Now we can add as many new instances managed nodes to configure them as a backend servers by just updating their IP’s to the inventory file and dynamically it will update it to the configuration file of haproxy.
So let’s configure one more backend server as a apache httpd webserver and host the same webpage by just adding its IP i.e 172.31.0.129 to the inventory file.

🔹Let’s check the connectivity

🔹Now Let’s Run the playbook :

🔹Checking our Load balancer haproxy config file which is updated dynamically :

🔹Now check our target node (Backend Server)

🔹Let’s check our webpage from the browser :


TASK COMPLETED Successfully✌🏻👨🏻💻
Thanks for reading !!!😊✨