Skip to content

Instantly share code, notes, and snippets.

@helloimalemur
Forked from lazywithclass/blog-post.md
Last active May 29, 2024 16:50
Show Gist options
  • Save helloimalemur/c704b4471afdb4a3dd0cea661a71343b to your computer and use it in GitHub Desktop.
Save helloimalemur/c704b4471afdb4a3dd0cea661a71343b to your computer and use it in GitHub Desktop.
Logging request body in HAProxy

Logging request body in HAProxy

add the following to the frontend section of your haproxy configuration

## ------ LOG REQ BODY ----------
option http-buffer-request
declare capture request len 40000000
http-request capture req.body id 0
log-format "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r %[capture.req.hdr(0)]"
## --------------------


## ------ LOG REQ BODY AND RES BODY ----------
option http-buffer-request
declare capture request len 40000000
declare capture response len 40000000
http-request capture req.body id 0
http-response capture res.body id 0
log-format "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r %[capture.req.hdr(0)] %[capture.res.hdr(0)]"
## --------------------

Example config ref

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment