I’m trying to find a way to have HAProxy automatically bind to an address when the address is added to an interface by the system.
I want HAProxy to listen to all the addresses of an interface. I don’t want to listen to the wildcard address. I also know that bind can be restricted to accepting connections on a specific interface in Linux (BINDTODEVICE), but it wouldn’t accept connections coming in from an unbound interface for the address of the bound interface.
I’m looking for a solution similar to DNSMasq’s
From what I understand it listens to Linux’s NetLink messages and automatically binds to addresses added to an interface.
Right now my current work around is to listen to address changes on the interface, pass the addresses as variables for HAProxy, and reload HAProxy on changes.
There are complications with this approach when the address isn’t yet available (interface down or the address wasn’t configured yet).
I’d also be happy with a solution that allows changing the bound address through a Unix socket command similar to the way a backend server address can be changed. The command could be something like
set bind <frontend>/<so_id> addr <ip4 or ip6 address> [port <port>].
It would be nice in that case to allow a bind configuration that doesn’t actually bind to anything, but is just there waiting to be configured by the management socket.
The issue I see with this runtime binding is privileged ports and HAProxy dropping root. It would require HAProxy to keep the