Di lingkungan saya, saya memiliki keseimbangan beban haproxy untuk 2 server web (Apache), ini adalah konfigurasi HA Proxy saya:
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
tune.ssl.default-dh-param 2048
daemon
nbproc 1
stats socket /var/lib/haproxy/stats
stats timeout 1m
nogetaddrinfo
listen front
bind :80
redirect scheme https if { hdr(Host) -i domain.com } !{ ssl_fc }
listen front_ssl
bind :443 ssl crt /opt/certificate/domain.pem
mode http
option dontlognull
stats enable
stats uri /ha?stats
stats realm system
stats auth root:*********
stats refresh 5s
option http-keep-alive
option forwardfor
option redispatch
reqadd X-Forwarded-Proto:\ https if { ssl_fc }
timeout client 15s
timeout connect 3s
timeout server 15s
timeout http-request 15s
timeout http-keep-alive 15s
default_backend bk_http
backend bk_http
mode http
balance source
option http-keep-alive
default-server inter 1s
retries 3
timeout connect 3s
timeout server 15s
timeout queue 60s
timeout check 10s
timeout http-request 15s
timeout http-keep-alive 15s
server node1 1.2.3.4:82 check id 1 weight 1 maxconn 2000 maxqueue 2000
server node2 5.6.7.8:82 check id 1 weight 1 maxconn 2000 maxqueue 2000
"KeepAlive On" di /etc/httpd/conf/httpd.conf Tetapi ketika saya menguji dengan curl, saya melihat bahwa keepalive tidak berfungsi:
curl -Iv http://domain.com 2>&1 | grep -i 'connection #0'
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Closing connection #0
curl -Iv https://domain.com 2>&1 | grep -i 'connection #0'
* Closing connection #0
Seperti yang saya tahu jika keepalive berfungsi, hasilnya seharusnya:
0 162 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0* Connection #0 to host domain.com left intact
* Closing connection #0
Tolong beri tahu saya jika ada yang salah dalam konfigurasi saya?