TransWikia.com

Can haproxy log unknown headers?

Server Fault Asked by cbaltatescu on December 26, 2020

I need to take a look at all the headers of certain requests. I’ve been reading the haproxy manual, I am able to use capture to log whatever header I KNOW is there.

But I would like to see ALL the headers, unknown to me, that the app receives. Is this possible with haproxy’s logging options? Some sort of regexp or iteration method?

I am using haproxy 1.6

Thank you.

2 Answers

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.

Answered by Mikhail Efremov on December 26, 2020

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>

Answered by HBruijn on December 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP