Wie zu machen, HA-Proxy keepalive
In meinem Umfeld habe ich haproxy Loadbalancing für 2 Webserver (Apache), dies ist mein HA-Proxy-Konfiguration :
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" in /etc/httpd/conf/httpd.conf
Aber wenn ich den test mit curl, sehe ich, dass keepalive wird nicht funktionieren :
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
Als ich weiß, wenn keepalive funktioniert, das Ergebnis sollte sein :
0 162 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0* Connection #0 to host domain.com left intact
* Closing connection #0
Bitte lassen Sie mich wissen, wenn etwas falsch in meiner Konfiguration ?
- Im Gegensatz zu den forum-Seiten, die wir nicht nutzen "Danke", oder "Jede Hilfe zu schätzen", oder Signaturen, die auf Stack-Overflow. Siehe "Sollte 'Hallo', 'danke,' Slogans und Begrüßungen entfernt von posts?. BTW, ist es "Dank im Voraus", nicht "vielen Dank im fortgeschrittenen".
Du musst angemeldet sein, um einen Kommentar abzugeben.
Haben Sie die richtige Konfiguration. Sie benötigen lediglich
option http-keep-alive
das ist der Standardwert, der von haproxy 1.5. Sie überprüfen, welche version Sie installiert haben.Sehen http://www.haproxy.org/download/1.5/doc/configuration.txt Abschnitt 4. Proxies
Ihre backends, node1/node2, sind wahrscheinlich schließen der Verbindung. Haben Sie vielleicht nicht keepalives aktiviert.
Wenn Sie abzufangen, den Datenverkehr überprüfen für http/1.1 und nicht "Connection: close" header