Can haproxy log unknown headers?

Try to use (in /etc/haproxy/haproxy.cfg):

frontend my_frontend
  mode http
  option httplog
  http-request capture req.hdrs len 512
  log-format "%ci:%cp [%tr] %ft [[%hr]] %hs %{+Q}r"

req.hdrs - Returns the current request headers as string including the last empty line separating headers from the request body
%hr - print captured request headers

Hope this helps.


You log known headers with capture request header directive but HAproxy 1.6 introduces a new directive, the http-request capture syntax.

http-request capture <sample> [ len <length> | id <id> ] :
captures sample expression <sample> from the request buffer, and converts it to a string of at most <len> characters. The resulting string is stored into the next request "capture" slot, so it will possibly appear next to some captured HTTP headers. It will then automatically appear in the logs, and it will be possible to extract it using sample fetch rules to feed it into headers or anything. The length should be limited given that this size will be allocated for each capture during the whole session life. Please check section 7.3 (Fetching samples) and "capture request header" for more information.

which I think you can configure to use regex expressions as <sample>