Is there a way to close a listener port when all backends went down?

I’ve deployed multiple haproxys instances inside multiple clusters (one for each). There is a router-like device (which I can’t modify) sitting in front of all clusters . As expected, requests will be distributed by router to haproxys and then to my backends under normal situation. However, when all backends inside a cluster go down, that haproxy can still get requests sent by the router, and thus cause a failure. So my goal is to make haproxy to close its listening port when all its backends went down, so that the router can detect this in order to ignore this haproxy. Is there a way to achieve this?

No, this is not supported within haproxy. Also, haproxy drops privileges after the initial bind, so closing and re-binding in service is not possible.

You would have to script this (monitoring the backends, then installing some iptables rules that reject incoming connection attempts).

Thanks a lot. Looks like I have to solve this outside haproxy anyway