Hi,
I would like to share with you the current HAProxy code for Web and App system
Code Web Server:
#--------------------------------------------------------
Global settings
#---------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option dontlognull
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
#------------------ Start ---------------------
frontend ft_http
bind *:880
mode http
default_backend bk_http
frontend ft_https
bind *:8443
mode tcp
default_backend bk_https
backend bk_http
mode http
balance roundrobin
server Web1 10.100.3.131:80 check
server Web2 10.100.3.132:80 check
backend bk_https
mode tcp
balance roundrobin
server Web1 10.100.3.131:443 check
server Web2 10.100.3.132:443 check
peers Mypeer
peer HA1 10.100.3.131:1024
peer HA2 10.100.3.132:1024
#------------ Start HAPRoxy Status page ---------------------
listen stats
bind *:1978
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /stats
stats auth admi:admin
#---------------End HAPRoxy Status page ----------------------
Code Application Server:
#---------------------------------------------------------------------
Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode tcp
log global
option tcplog
option dontlognull
option redispatch
retries 3
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s
maxconn 3000
#---------- Start -----------------------------
frontend haproxy_inbound
bind *:8888
mode tcp
default_backend LB
backend LB
balance roundrobin
mode tcp
server APP1 10.31.24.231:8109 check
server APP2 10.31.24.232:8109 check
peers Mypeer
peer LB1 10.31.24.231:1024
peer LB2 10.31.24.232:1024
#--------------- HAProxy Status Page---------
listen stats
bind *:1978
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /stats
stats auth admin:admin
#-------------End --------------------------
Keepalived Code in all Server with different priority for node MASTER and node BACKUP
Start Keepalived1
#--------------------------------------------------
vrrp_script chk_haproxy {
script “pidof haproxy”
interval 2
}
vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 10
priority 150
vrrp_unicast_bind 10.100.3.131 #Internal IP of this node
vrrp_unicast_peer 10.100.3.132 #Internal IP of Backup node
virtual_ipaddress {
10.100.3.130
}
track_script {
chk_haproxy
}
}
#----------------------------------------------------
End Keepalived1
#----------------------------------------------------