This blog is about how we can Configuring Reverse Proxy i.e. Haproxy and updating it’s configuration file automatically on each time new Managed node (Configured With Apache Webserver) join the inventory.

So What HAProxy actually is..?

HAProxy is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers. It is written in C and has a reputation for being fast and efficient (in terms of processor and memory usage).

🔹First we have to update the Ip addresses in Inventory file(#vim /root/ip.txt) of controller node on which we want to configure something.

🔹Ansible Configuration file

In this file have to update Inventory file location .The path of file is #vim /etc/ansible/ansible.cfg.

Now check the connectivity of Managed Nodes with Controller Node.

#ansible all -m ping all command is used to check the connectivity.

Now we see our Ansible Playbook

🔹Ansible playbook

host: load_balancer ➯ For Load balancer

host: b_server ➯ For Backend server

🔹HAProxy file configuration

🔹 Running Playbook

Now we are done with the Controller node configuration..!!

Lets check it manually on managed node.

🔹Managed node

Lets have a look of what we configured actually.

Load balancer:-

⭐HAproxy service started⭐
⭐HAproxy config file⭐

here you could see that this file is dynamically updated with the Ip of the Backend server.

🔹checking on browser

Now we can add as many new instances as 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 with the same webpage by just adding its IP i.e 192.168.43.101 to the inventory file.

Now Ping again ,just to confirm that new instance is pinging or not

Now we just have to run the playbook again and thats it.

This server is launched successfully.

Lets check whether this Backend server is updated in Haproxy file of loadbalancer or not.

🔹Checking haproxy config file

🔹Finally ..lets check both the servers on browser.

Hence verified..!!

✨Loadbalancer is working very fine…✨

For Furthur Queries, Suggestion’s Feel Free to Connect with me On Linkedin.

www.linkedin.com/in/rohit-bhatt-97499b188.

Thank you!!!!!!!!!

--

--