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.

Shashwat Singh
2 min readDec 31, 2020

--

There are three machines which one of them work as Load Balancer Device and other two are work as Webserver (Means where application is hosted).On the fly we need to update the Haproxy configuration with the IP’s of the App Hosted Machines.

IP info

A (Work as Load Balancer Device)→ IP(192.168.56.101)

B( App Hosted Machine) →IP(192.168.56.104)

C(App Hosted Machine) →IP(192.168.56.103)

First Configure the Inventory File.. From where we easily access the IP as well as username and pass for ssh for Ansible....

Inventory file For the Loadbalancer

Configure A and B machine and also we are going host an index.php page which will show the output of (ifconfig command) on page…

index.php file
webserver conf script file

Now we will configure the LoadBalancer.

First Configure the haproxy configuration file in such a way so that it will scan the inventry file and automaticaly retrive the IP of App hosted machines (by the help of jinja template we implemented this ).

haproxy conf file

--

--

Shashwat Singh
Shashwat Singh

Written by Shashwat Singh

Cyber Security Enthusiasm || DevOps || Backend Development || Linkedin -https://www.linkedin.com/in/shashwatsing/ || Github - https://github.com/Shashwatsingh22

No responses yet