I have an HAProxy configuration with a custom JSON log-format. I want to capture a specific response header and log it.
However, no matter how I try to capture it, I cannot make it appear in the log.
In my log format I use %[capture.res.hdr(0)] but it only comes up as -. I've also tried %[res.hdr(0)] and %[res.hdr(MyHeader)] but they were not valid configuration and HAProxy failed to start.
I've tried capturing using:
capture response header MyHeader len 50
But it doesn't work. I also tried:
declare capture response len 50
http-response capture res.hdr(MyHeader) id 0
With no success. The %hs format variable works - all the captured headers are logged in a delimited string. But I want to log the headers separately as JSON properties.
What am I doing wrong?
I'm currently using HAProxy 1.8.