Custom http-request header not getting logged

I have custom header set and it is not getting logged (i.e I am unable to see in the haproxy log)

Here is my configuration

frontend haproxynode
bind *:80
mode http
log global
timeout client 60000
maxconn 50000

acl host_abhi hdr_beg(host) -i -f /Users/abpatti/haproxy/test/testing.lst

http-request deny if !host_abhi

http-request add-header validtest %H if host_abhi
http-request add-header invalidtest %H if !host_abhi 
capture request header validtest len 64
capture request header invalidtest len 64
http-request set-header X-Custom-Header %[url]
capture request header X-Custom-Header len 64
log-format %{+Q}o\ %{-Q}ci\ -\ -\ [%T]\ %r\ %ST\ %B\ %cp\ %ms\ %ft\ %b\ %s\ \%TR\ %Tw\ %Tc\ %Tr\ %Tt\ %tsc\ %ac\ %fc\ %bc\ %sc\ %rc\ %sq\ %bq\ %CC\ %CS\ %hrl\ %hsl\ %sslv\
use_backend backendnodel

Here is what I see in the log

Sep 18 09:44:57 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:57 +0000] “GET / HTTP/1.1” 200 155 61669 163 “haproxynode” “backendnodel” “127.0.0.1” \0 0 1 1 2 ---- 1 1 0 0 0 0 0 “” “” “” “” “” “”
Sep 18 09:44:57 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:57 +0000] “GET /favicon.ico HTTP/1.1” 200 155 61669 166 “haproxynode” “backendnodel” “127.0.0.1” \0 0 0 0 127 ---- 1 1 0 0 0 0 0 “” “” “” “” “” “”
Sep 18 09:44:59 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:59 +0000] “GET / HTTP/1.1” 200 155 61672 843 “haproxynode” “backendnodel” “127.0.0.1” \0 0 0 0 0 ---- 2 2 0 0 0 0 0 “” “” “” “” “” “”
Sep 18 09:44:59 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:59 +0000] “GET /favicon.ico HTTP/1.1” 200 155 61672 843 “haproxynode” “backendnodel” “127.0.0.1” \0 0 0 1 123 ---- 2 2 0 0 0 0 0 “” “” “” “” “” “”
Waiting for data… (interrupt to abort)

The reason I say acl is working fine because, on the backend server I am printing the custom headers and I am unable to see the values

You can’t capture a header that haproxy emits itself.

Thanks

Found the solution for the issue.

I had to use http-request capture req.hdr(validtest) len 64

1 Like