Using HAProxy version: 2.8.7
I am trying to add request headers to log entries for testing purposes. However, I am apparently doing something incorrectly.
Here are what I consider to be the relevant parts of the config file:
global
log stdout len 65535 format raw local0
defaults
mode http
option httplog
frontend http-ingress
log global
http-request set-var(txn.host) req.hdr(Host)
http-request set-var(txn.agent) req.hdr(User-Agent)
log-format "host: %[var(txn.host)], agent: %[var(txn.agent)]"
The log output is:
host: !,(BADINDEX) agent: !(BADINDEX)
If I use req.hdrs
instead:
log-format "http_request_headers: %{+Q}[var(txn.req_hdrs)]"
http-request set-var(txn.req_hdrs) req.hdrs
The log output is:
http_request_headers: !{(MISSING)+Q}[var(txn.req_hdrs)]
What am I doing wrong?