HAProxy community

Output haproxy backend's TCP client port in the logs

Context: I have a HAProxy configured to proxy TCP traffic for websockets. So a TCP redirecting session looks like this:

client app --> [(frontend) haproxy (backend)] --> server app

From the server’s perspective, the TCP client that establishes the TCP connection is the HAProxy’s backend. When this new connection is established, it’s possible for me to know the TCP client’s port (in other words, the port of the HAProxy backend’s TCP client connection).

Question: Is there a way to display this client’s port in the logs? Not the client app’s port, but really the backend’s tcp client port. Basically, I would like to have a way to correlate the socket I have on the server with a session on haproxy.

What I tried: I looked in the doc to customize the TCP log format and I tried to find a field that would give me the info I need, but nothing seems to fit.