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.