Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Created August 20, 2021 14:30
Show Gist options
  • Save haproxytechblog/cdf75a1636eab81d11bf9e6d49c40fd3 to your computer and use it in GitHub Desktop.
Save haproxytechblog/cdf75a1636eab81d11bf9e6d49c40fd3 to your computer and use it in GitHub Desktop.
How to Enable Health Checks in HAProxy
backend webservers
server server1 192.168.50.2:80 check
server server2 192.168.50.3:80 check
server server3 192.168.50.4:80 check
server server1 192.168.50.2:80 check inter 10s fall 5 rise 5
backend webservers
option httpchk
server server1 192.168.50.2:80 check
server server2 192.168.50.3:80 check
server server3 192.168.50.4:80 check
backend webservers
option httpchk
http-check send meth GET uri /health
server server1 192.168.50.2:80 check
server server2 192.168.50.3:80 check
server server3 192.168.50.4:80 check
backend webservers
option httpchk
http-check send meth POST uri /health hdr Content-Type application/json body "{ \"foo\": \"bar\" }"
server server1 192.168.50.2:80 check
server server2 192.168.50.3:80 check
server server3 192.168.50.4:80 check
backend webservers
option httpchk
http-check connect
http-check send meth GET uri /health
http-check expect status 200
http-check connect
http-check send meth GET uri /health2
http-check expect status 200
server server1 192.168.50.2:80 check
server server2 192.168.50.3:80 check
server server3 192.168.50.4:80 check
http-check connect ssl alpn h2,http/1.1
backend webservers
option httpchk
http-check send meth GET uri /health
http-check expect status 200
server server1 192.168.50.2:80 check
server server2 192.168.50.3:80 check
server server3 192.168.50.4:80 check
http-check expect string success
backend webservers
option httpchk
http-check send meth GET uri /health
server server1 192.168.50.2:80 check observe layer7 error-limit 50 on-error mark-down
backend webservers
balance roundrobin
server server1 192.168.50.2:80 check weight 100 agent-check agent-inter 5s agent-addr 192.168.50.2 agent-port 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment