I have configured a Software Load balancer with HAProxy.
- Here are the details :
- Load Balancer 1 (Master) - 10.0.0.2
- Load Balancer 2 (Slave) - 10.0.0.3
- Virtual IP that load balancer shared is - 10.0.0.1
- Web Server 1 with Apache : 10.0.0.4
- Web Server 2 with Apache : 10.0.0.5
- Web Server 3 with Apache : 10.0.0.6
I am able to access the website hosted on all Webservers through Virtual IP configured i.e 10.0.0.1
But, when i refresh the browser, the servers are getting switched from one to another. Also, getting error "503 Service Unavailable", that too when refreshed, goes to another server.
Here is the HAProxy.conf file content [Master Load Balancer]:
global
log 127.0.0.1 local0 err
ulimit-n 50000
maxconn 24000
nbproc 1
stats socket /tmp/haproxysock
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
maxconn 5000
contimeout 5000
clitimeout 50000
srvtimeout 50000
frontend UNBoxFrontEnd
bind 10.0.0.1:80
option http-server-close
default_backend UNBoxBackEnd
backend UNBoxBackEnd
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
hash-type consistent
cookie JSESSIONID prefix
server WebServer1 10.0.0.4:80 cookie Web1 check
server WebServer2 10.0.0.5:80 cookie Web2 check
server WebServer3 10.0.0.6:80 cookie Web3 check
listen web-cluster 10.0.0.1:80
bind *:1936
balance roundrobin
stats enable
stats scope UNBoxFrontEnd
stats scope UNBoxBackEnd
stats scope wordpress-backend
stats uri /haproxy?stats
stats realm Haproxy\ Statistics
stats auth test:test
stats admin if TRUE
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
Can you please help me out to make client always redirected to a single Webserver unless that goes down.
Thanks in advance!