Slightly related to " Other options to "balance source" in haproxy", I would like to know what ports are currently pointed where.

To confirm, I'm using haproxy to distribute clients which make only a single connection at a time to a different port on the proxy, to different backend servers. Assume the protocol is ssh.

I'm using a stick-table to keep clients to one backend server until that server goes down. What's the best way to find out what the current state is?

I know I could make one frontend for each port then point them all at the same backend. The name of the frontend is then logged but i can't help but want one neat frontend with a range of ports and then dst_port logged.

  • I guess there's always the choice of seeing if I can patch the logging to include dst_prt... Wonder if there's a reason why that's 'hard' or a bad idea. – Pricey May 20 '11 at 15:22

My current answer/solution (mentioned in the question) is as follows.

I define a different 'listen' for each port to be bound with a recognisable name.

I then ensure option tcplog is enabled for that frontend.

The logging then provides me the two pieces of information I need. The frontend and backend used.


haproxy[18989]: [15/Oct/2003:15:24:28.312] frontend backend/server 0/0/5007 0 cD 0/0/0/0/0 0/0

I parse that log file 'magically' and use that information to present the latest status.

option logasap helps..

  • One of the downsides to this is it doesn't take into account stick-table expire times unless you're clever. – Pricey May 20 '11 at 14:11

Default tcplog format is equivalent to:

log-format "%ci:%cp [%t] %ft %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq"

So, you can customize it adding variables of your interest (list of defined variables), e.g frontend listening port %fp:

log-format "%ci:%cp [%t] %ft %fp %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq"

I'm not sure if this is what you need.

You can enable the stats on the HAProxy configuration, adding this lines in the :80 port config

stats enable

Then you can go to the URL: http://YOURDOMAIN-OR-IP/haproxy?stats

There you can see the status and redirection HAProxy is doing at any time.

  • I'm afraid that doesn't give you the status of the stick-table like I would like. – Pricey May 19 '11 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.