Sitemap

Configuring Reverse
Proxy and update it’s configuration
file automatically on each time new Managed node join the inventory on local machine

3 min readMay 12, 2021
Press enter or click to view image in full size

This blog will explain you how to setup reverse proxy and to configure it automatically every time you attach new managed node.

Press enter or click to view image in full size

Below are the machines I have launched according to above picture -

* Namenode -

rhel8_arth — 192.168/29.202 — machine on which ansible script will run.

* Datanode

rhel-exp-2–192.168.29.225 — machine on which haproxy will configure.

rhel-cli — 192.168.29.201 — machine-1 on which web server-1 will run.

rhel-cl-2–192.168.29.24 — machine-2 on which web server-2 will run.

Press enter or click to view image in full size

Now go to your namenode(rhel8_arth) machine and configure its inventory file by as -

Press enter or click to view image in full size

Make a directory and put your yml file and cfg(configuration file of haproxy)

both file in that directory.

Press enter or click to view image in full size

Below is the script …

Press enter or click to view image in full size
..
Press enter or click to view image in full size

Do the changes in haproxy.cfg.j2 file as show below.

I have used jinja code so that it can dynamically update it self to configure haproxy.

Bind keyword as shown in below rectangle shows that haproxy runs on 8081 port number.

second rectangle is use to update ip address of the instances where web server runs.

Press enter or click to view image in full size

After all above configuration run the script

ansible-playbook lb.yml
Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

As the script runs successfully, now go to instance where you run haproxy server and web servers and check their status by the command —

systemctl status haproxy
systemctl status httpd
Press enter or click to view image in full size
instance running haproxy
Press enter or click to view image in full size
instance running web server 1
Press enter or click to view image in full size
Instance running web server 2

Now go to browser and check whether haproxy server is running or not

ip_address_of_haproxy_instance:port_number/index.html
Press enter or click to view image in full size

Thank you

Harsh Agrawal

https://github.com/HarshAgrawal25/Ansible/tree/master/Ansible%20playbook%20for%20haproxy%20and%20load%20balancer

--

--

No responses yet