HAProxy is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers. It is written in C and has a reputation for being fast and efficient.
As we are using ansible on top of AWS ,We need to configure the ansible configuration file .
Here in my case I created a separate workspace where I kept all configuration file all yaml file ,So that it can be organised and easily used when needed .
In ansible configuration file I also mentioned the private key for the ansible to do the authentication part very easily .
Coming to the haproxy configuration file, which I would be sending from my controller node to all the managed node .
Here I used ‘for loop’ in Jinja language for printing Groups (apache) Value(Ip’s present in that group)
I created the architecture in the type, like in future it would automatically update it’s configuration file on each time new Managed node join the inventory.
Let’s look onto the host file.
Now when my playbook runs , It would automatically launch a webserver with a Load Balancer or Reverse proxy configured and also start the services .
After playbook runs ,explaining what is going on..
After running the Playbook ,It would first go to “apache” group in the inventory and in all those Ip’s go and launch Apache httpd Webserver and start the services.
Next step, It would now go to “haproxy” group in the inventory and then in that Ip it launches HAproxy and then copy the configuration file from controller node which would parse all the Ip’s from ‘apache” group and then update it to the managed Node ,Now it launches HAproxy services .
Finally, here is my small architecture on top of AWS which consist of a Load Balancer or Reverse Proxy at the Frontend and Apache Webserver at the backend .
For demonstrating you all ,I changed the webpage with 1 and 2 ,So that you’ll can easily figure out reverse proxy is working .