HAProxy (High Availability Proxy) is a Open source software for TCP/HTTP Loadbalancing and proxying solution that can be run in linux, macos and freeBSD. HAProxy is used for improve performance and reliability of server that distributing the workload into multiple server.
There are the topology are used :
Make sure you’re have configured ip address on each servers.
Install the Haproxy service on haproxy server :
root@HAProxy:~# apt-get install haproxy
Configure web server on WEB1 and WEB2.
root@WEB1:~# echo "THIS IS WEB1" > /var/www/html/index.htmlroot@WEB2:~# echo "THIS IS WEB2" > /var/www/html/index.html
And then Configure on HaProxy server . Do the configuration at /etc/haproxy/haproxy.cfg
Setting on defaults section like this :
timeout connect 5s timeout client 10s timeout server 10s
Add the Frontend and Backend Configuration in the bottom section.
frontend MySV bind *:80 mode http default_backend myBC backend myBC balance roundrobin server server1 10.100.1.2:80 check server server2 10.100.1.3:80 check
Then restart the haproxy service :
root@HAProxy:~# systemctl restart haproxy
After that, do the test on your client :
First access :
Second access :