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

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

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.

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

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

both file in that directory.

Below is the script …

..

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.

After all above configuration run the script

ansible-playbook lb.yml

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
instance running haproxy
instance running web server 1
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

Thank you

Harsh Agrawal

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

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Torah AMA: Web3 with Distributed Storage

AWS Docker Gitlab Serverless - The easy way.

Photo form: https://www.freeimages.com/es/photo/communicate-1-1241953

7 Agile Project Management Tools that you should Know

Java Lombok Tutorial by OnlineTutorials

Docker : In Layman Terms

How to Easily Explore a Python Library With Real Data

WINJA CTF: SSH

Fundamentals of networking in AWS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harsh Agrawal

Harsh Agrawal

Learner

More from Medium

Adding features to Sphero Pong

Needed: Financing Policies That are Both Affordable AND Sustainable

Intermezzo: A Kew Gardens Fall/Winter Meditation

Naim Audio — Servicing & DR Upgrades