My requirement is to have ~50 haproxy http backends, which will be added and removed dynamically (without my involvement) anywhere on the internal network. I can assume that each http backend knows its IP address and knows the IP address of haproxy. I can assume that I can add a little bit of code to each http backend, to allow it to register with haproxy whenever it spins up and deregister before it spins down.
I have haproxy listening on port 80:
frontend main *:80
Additionally I expose a stat socket:
stats socket 0.0.0.0:8080
My setup works & in particular I can connect to the stats socket using
socat readline TCP4:<haproxyIP>:8080
Let us assume that we have two http backends serving on
10.0.0.2:4040, and that haproxy can reach both addresses.
What stat socket command do I need to issue over the stat socket so that any request to
<haproxyIP>:8080/backend1/status is routed to
10.0.0.1:4040/status and any request to
<haproxyIP>:8080/backend2/version is routed to
In general: how do I dynamically proxy http requests from
[GET|POST] <haproxyIP>:<haproxyPort>/<backendID>/<remainingPath> to
[GET|POST] <backendIP>:<backendPort>/<remainingPath> given that I know a map from
backendID -> backendIP, backendPort.