Haproxy on server failure event

failoverhaproxy

I've got a setup with one HAproxy server (frontend) and multiple web-servers (backend). Is it possible to configure HAproxy so that a script is executed when a web-server gets down?

Best Answer

I think what you're asking is you want to send a mail when one of the backend servers goes down, correct? I don't believe there's a way to trigger this from within HAProxy itself. One way to do this is to have a script check the status of the backends periodically and send an email if a backend is down. You can use the HAProxy socket interface to get this info. Docs are here. You'll probably need to parse the output from the show stat command. Good luck!