Welcome back to my new blog🤗
In this blog, I am going to show you how to Configure Reverse Proxy i.e. Haproxy and update it's configuration file automatically each time a new Managed node (Configured With Apache Webserver) is added to the inventory, with the help of ansible playbook.
What is haproxy?
HAProxy is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP -based applications that spread requests across multiple servers.
Haproxy accepts a request from a client, forwards it to a server that can fulfill it, and returns the server's response to the client. A load balancer distributes incoming client requests among a group of servers, in each case returning the response from the selected server to the appropriate client
So now let's jump to the practical part:-
Here is my inventory file which contains two IP's one for the webserver(backend user) and another one for the load balancer(front-end user).
Now I am going to ping the system to check the connectivity.
command :- ansible all -m ping
Here ping pong msg shows that we are successfully connected ...
Playbook:-
Haproxy.cfg.j2 file, with the help of this file haproxy.cfg file will dynamically update when the new webserver is added.
Implementation:-
Let's see Target nodes configured or not
webserver:-
Here you can see that my files are copied successfully and also check that this system IP is (192.168.43.251).
2. Loadbalancer:-
Here our haproxy file is configured successfully.
IP of load balancer (192.168.43.53) and also in HTML dir, I don't have any web file.
Now I am going to check that the service is running or not properly
Here you can see that the IP which I am using is load balancer IP and data is from the webserver system. and as you can see our load balancer IP is fetching data from the webserver IP this shows that our configuration is successfully done.
تعليقات