What is Reverse Proxy?
A reverse proxy server is a type of proxy server that typically sits behind the firewall in a private network and directs client requests to the appropriate backend server. A reverse proxy provides an additional level of abstraction and control to ensure the smooth flow of network traffic between clients and servers.
Why We Need a Reverse Proxy?
You have a web server that can manage 100 clients at a time. Suddenly the requests to that particular server increase by 100 percent. It’s likely that the website will crash or be terminated. To avoid this situation, set up a target web server. In this scenario, the client never goes to the target web server. Instead, their request goes to the master server, and the master server sends the request to the target web server. When the target web server replies to the master web server, which is known as a reverse proxy.
What is The Round Robin?
“Round‑robin” load balancing is one of the simplest methods for distributing client requests across a group of servers. Going down the list of servers in the group, the “round‑robin” load balancer forwards a client request to each server in turn.
For achieving this setup we are going to use the Haproxy server. So without wasting any time let’s jump on practical.
My Ansible inventory file is shown here. For this setup, one computer(mylb group) will be configured as a load balancer and another two computers(webserver group) will get configured as Web servers.
Ansible Configuration file:
In My Case my inventory file and ansible configuration file store in one kind of workspace /ansible direcoty indise this we store inventory file & ansible.cfg file.
What is Apache Httpd WebServer?
This is the most popular web server in the world developed by the Apache Software Foundation. Apache web server is an open source software and can be installed on almost all operating systems including Linux, UNIX, Windows, FreeBSD, Mac OS X and more. About 60% of the web server machines run the Apache Web Server.
Step-1: Configure Webserver and demonstrate the Ansible Playbook
Step-2: Demonstrate the Reverse Proxy Ansible playbook
I Showing haproxy.cfg.j2 jinja template file:
Step-3: For running the ansible playbook we can use the following command.
# ansible-playbook balancer.yml
Now Let us Running Reverse Proxy playbook.
Here all tasks are done, so let’s crosscheck whether ansible has done the configuration or not
Checking IP of lb here status of haproxy is active. let us check the configuration file
You can see over here that ansible added entry dynamically as we want so finally load balancer setup is done. let us check web group IP/ system
So Now our setup is done. let us check is it working or not?
Thanks for reading… If any questions please feel free to leave a comment below and Do connect with me on these platforms.