I am trying to enable http checks to my backend servers and I am a bit stuck.
My haproxy.cfg is:
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE$
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
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
frontend vIDM
bind 10.10.1.83:80
bind 10.10.1.83:443 ssl crt /etc/ssl/vidmlb.momusconsulting.com-chain-with-pk.pem
mode http
option http-server-close
option forwardfor
http-request add-header X-Forwarded-Proto https
http-request add-header X-Forwarded-Port 443
redirect scheme https if !{ ssl_fc }
default_backend vIDM-be
backend vIDM-be
mode http
balance source
cookie JSESSIONID rewrite nocache
timeout check 2000
# option httpchk
# http-check connect port 443 ssl
# http-check send meth GET uri /SAAS/API/1.0/REST/system/health/heartbeat ver HTTP/1.1
# http-check expect status 200
server mc-vidm-v-201a 10.10.1.85:443 check ssl verify none
server mc-vidm-v-202a 10.10.1.86:443 check ssl verify none
server mc-vidm-v-203a 10.10.1.87:443 check ssl verify none
listen Stats
bind 10.10.1.80:8443 ssl crt /etc/ssl/mc-hapr-v-201a.momusconsulting.com-chain-with-pk.pem
stats enable
stats hide-version
stats refresh 1s
stats show-node
stats auth stats:password
stats uri /stats
When I un-comment the 4 hashed out lines in the ‘backend vIDM-be’ section and restart the haproxy service, I get Server vIDM-be/xx is DOWN, reason: Layer7 wrong status, code: 400.
Dec 01 13:58:54 mc-hapr-v-201a systemd[1]: Starting HAProxy Load Balancer…
Dec 01 13:58:54 mc-hapr-v-201a haproxy[3420]: [NOTICE] (3420) : New worker #1 (3434) forked
Dec 01 13:58:54 mc-hapr-v-201a systemd[1]: Started HAProxy Load Balancer.
Dec 01 13:58:54 mc-hapr-v-201a haproxy[3420]: [WARNING] (3434) : Server vIDM-be/mc-vidm-v-201a is DOWN, reason: Layer7 wrong status, code: 400, check duration: 18ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Dec 01 13:58:55 mc-hapr-v-201a haproxy[3420]: [WARNING] (3434) : Server vIDM-be/mc-vidm-v-202a is DOWN, reason: Layer7 wrong status, code: 400, check duration: 19ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Dec 01 13:58:55 mc-hapr-v-201a haproxy[3420]: [WARNING] (3434) : Server vIDM-be/mc-vidm-v-203a is DOWN, reason: Layer7 wrong status, code: 400, check duration: 17ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Dec 01 13:58:55 mc-hapr-v-201a haproxy[3420]: [NOTICE] (3434) : haproxy version is 2.4.9-1ppa1~bionic
Dec 01 13:58:55 mc-hapr-v-201a haproxy[3420]: [NOTICE] (3434) : path to executable is /usr/sbin/haproxy
Dec 01 13:58:55 mc-hapr-v-201a haproxy[3420]: [ALERT] (3434) : backend ‘vIDM-be’ has no server available!
When I curl the same url, I get a HTTP status 200/ok as expected.
root@mc-hapr-v-201a:/etc/haproxy# curl -vv https://mc-vidm-v-201a.momusconsulting.com/SAAS/API/1.0/REST/system/health/heartbeat
* Trying 10.10.1.85...
* TCP_NODELAY set
* Connected to mc-vidm-v-201a.momusconsulting.com (10.10.1.85) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=GB; ST=Hampshire; L=Basingstoke; O=Momus Consulting; OU=Momus Labs; CN=vidmlb.momusconsulting.com
* start date: Nov 30 15:04:59 2021 GMT
* expire date: Nov 29 15:04:59 2026 GMT
* subjectAltName: host "mc-vidm-v-201a.momusconsulting.com" matched cert's "mc-vidm-v-201a.momusconsulting.com"
* issuer: DC=com; DC=momusconsulting; CN=MomusInterCA
* SSL certificate verify ok.
> GET /SAAS/API/1.0/REST/system/health/heartbeat HTTP/1.1
> Host: mc-vidm-v-201a.momusconsulting.com
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 200
< Cache-Control: no-cache, no-store, must-revalidate
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Strict-Transport-Security: max-age=31536000
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Content-Security-Policy: object-src 'none'; default-src blob: https: 'self' ; script-src 'unsafe-inline' 'unsafe-eval' https: 'self' ; style-src 'unsafe-inline' https: 'self'; img-src https: data: 'self'
< Set-Cookie: JSESSIONID=5D489A593C66497297D185655A4135A0; Path=/; Secure; HttpOnly
< P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
< Content-Type: text/plain;charset=ISO-8859-1
< Content-Length: 2
< Date: Wed, 01 Dec 2021 14:03:10 GMT
<
* Connection #0 to host mc-vidm-v-201a.momusconsulting.com left intact
okroot@mc-hapr-v-201a:/etc/haproxy#
I have been chasing my tail for an hour and I cannot see what I am doing wrong?
Any help will be greatly appreciated.
Cheers,
M