Frontend IP and ports not logged in TCP mode, custom log format (%fi %fp)

Hi there!
I am trying to have HAProxy log the frontend’s IP and port for the client side. I am running haproxy 1.5.14 on RHEL 7.2

These are the relevant configuration parts:

defaults
    mode                    tcp
    log                     global
    log-format %H\ [%t]\ %ci:%cp->%fi:%fp(%ft)\ %bi:%bp->%si:%sp(%s)\ %Tw/%Tc/%Tt\ %U/%B\ %ts\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq

listen Test
    bind 192.168.0.1:2291  # external interface
    bind 10.0.0.1:2291     # internal interface
    server test-src2 10.0.1.100:2291 source 10.0.0.2

Now: Everything works like a charm, but the log looks like this:
Jun 20 14:50:16 localhost haproxy[16961]: testbox [20/Jun/2017:14:50:11.149] 102.168.0.100:61923->:0(Test) 10.0.0.2:5647->10.0.1.100:2291(test-src2) 1/0/5653 18/48 -- 0/0/0/0/0 0/0

As you see, is the log part “%fi:%fp” expanded into ":0 . I would expect the frontend destination IP and port. What am I missing?

Thanks for the report, this a bug (and a very old one too, yet you are the first one to notice).

I reported the issue along with some details on the mailing list:
https://www.mail-archive.com/haproxy@formilux.org/msg26508.html

All releases supporting “log-format” are affected (1.5+).

1 Like

Fix is committed:
http://git.haproxy.org/?p=haproxy.git;a=commit;h=d02286d6c866e5c0a7eb6fbb127fa57f3becaf16

There is workaround: replace %fi:%fp with %[dst]:%[dst_port]