HAProxy community

Custom backend according to an external script?

#1

I’m TPROXYing to one of three backends for a custom TCP protocol; this is not HTTP.

I’m trying to figure out if there is a way to do a network call (to, for example, have haproxy call http://10.4.2.15:8080/pass/<source IP here> and read a response), and the response will be 1, 2, or 3. If it is 1 or 2, forward tproxy to backend1. If it is a 3, forward tproxy to different backend3. Understandably this will also slow down connects, but that’s acceptable. My backends are running cloudflare’s mmproxy to read the source IP.

I’ve read there is Lua support, but unsure if it is just for scripting basic if statements or if it’s a full lua implementation that also allows for importing libraries(?) or network access.

0 Likes

#2

LUA can be used to connect to databases like redis and you also should be able to make a HTTP request, so yes, this should be possible with LUA.

0 Likes