A
A
Alyosha2020-12-16 22:29:03
HAproxy
Alyosha, 2020-12-16 22:29:03

Is it possible to add a custom package to HAproxy when connecting (similar to send-proxy)?

Actually the essence of the issue in the topic.

frontend testfront
  bind 0.0.0.0:1234
  mode tcp
  use_backend testback
backend testback
  mode tcp
  server test destantion:1234 send-proxy

It is necessary for each client immediately after the send-proxy package (or before it) to somehow transfer a custom server identifier to the endpoint, for example, the string "1234", then communicate with the client. Did a search, didn't find anything. If HAproxy does not know how to do this, you can tell me other proxies that can transfer both IP and custom connection packets for TCP.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alyosha, 2020-12-19
@peredozo

The issue is resolved, if anyone suddenly needs it, it is done through LUA:
haproxy.cfg:

global
  lua-load /path-to/script.lua
frontend testfront
  bind 0.0.0.0:1234
  mode tcp
  tcp-request content lua.testfunc testvalue
  use_backend testback
backend testback
  mode tcp
  server test destantion:1234 send-proxy

script.lua:
core.register_action("testfunc", { "tcp-req" }, function (txn, varfromconfig)
  txn.req:send("TEST " .. varfromconfig .. "\n")
end, 1)

This passes the string "TEST testvalue" to the backend after send-proxy.
If someone knows a more beautiful version without LUA - share.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question