The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,483 other followers

Logging request body in HAProxy · GitHub

Posted by jpluimers on 2020/10/05

I will likely need this one day: [WayBack] Logging request body in HAProxy · GitHub.



Logging request body in HAProxy

On the 14th of October HAProxy 1.6 was released! Among all features announced I am particularly interested in the ability to log the body of a request.

It wasn’t straightforward for me to understand how to do that, which is why I’m blogging it.

The relevant part could be found in the “Captures” section of the announcement, this is how I changed it to suit my needs:

# you need this so that HAProxy can access the request body
option http-buffer-request
# declare a capture slot giving it a max length (400) and a reference (0)
declare capture request len 400
http-request capture req.body id 0
# log it
log-format {"%[capture.req.hdr(0)]"}

I’ve create a small configuration file that could help you start experimenting with this feature.

By default it will also be logged in the %hs variable, have a look at the docs section about logging for more information.

view raw

hosted with ❤ by GitHub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: