4

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.

Pricey
  • 419
  • 1
  • 5
  • 20
  • 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

3 Answers3

1

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.

e.g.

haproxy[18989]: 127.0.0.1:34550 [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..

Pricey
  • 419
  • 1
  • 5
  • 20
  • 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
1

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"
-1

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
stats auth YOURUSERNAME:YOURPASSWORD

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.

Felipe Rojas
  • 649
  • 5
  • 7