In this previous post instructions were written on how to setup a Round Robin Load Balancer by using NGINX and a virtual IP that would pass requests to the Apache Web Servers.
In this post we will use the very same setup but we place a HAProxy server in front of the Virtual IP the NGINX servers created. This server will use the Round Robin protocol as well and it will pass the requests to the NGINX servers which will in return will pass the web requests to the Apache web servers. SSL is not yet implemented.
The IP address of the HAProxy is 10.0.0.52 and the IP address of the virtual IP we created is 10.0.0.44 with a DNS entry “wordpressvirtip”
yum install haproxy vi /etc/haproxy/haproxy.cfg
global log 127.0.0.1 local0 log 127.0.0.1 local1 debug maxconn 45000 # Total Max Connections. daemon nbproc 1 # Number of processing cores. defaults timeout server 86400000 timeout connect 86400000 timeout client 86400000 timeout queue 1000s # [HTTP Site Configuration] listen http_web 10.0.0.52:80 mode http balance roundrobin # Load Balancing algorithm option httpchk option forwardfor server wordpressvirtip 10.0.0.44:80 weight 1 maxconn 512 check #server server2 10.0.0.40:80 weight 1 maxconn 512 check # [HTTPS Site Configuration] #listen https_web 192.168.10.10:443 # mode tcp # balance source# Load Balancing algorithm # reqadd X-Forwarded-Proto:\ http # server server1 192.168.10.100:443 weight 1 maxconn 512 check # server server2 192.168.10.101:443 weight 1 maxconn 512 check
system start haproxy