配置 HAProxy 以记录请求 BODY
Configure HAProxy to Log Request BODY
我知道从 1.6.0 版开始可以使用 HAProxy 记录 POST 请求的主体。下面的mail archive表示我们需要以某种方式使用req.body并以日志格式记录capture.req.hdr。
上面提问的人 link 在他们的配置中有以下前端:
frontend www-http
bind 0.0.0.0:9000
option http-buffer-request
declare capture request len 400000
http-request capture req.body id 0
log-format {"%[capture.req.hdr(0)]"}
但大概这是错误的,因此他们的问题。
执行此操作的确切语法是什么?
自定义日志格式对我有用:
global
log 127.0.0.1 local0
debug
maxconn 2048
ulimit-n 8012
# ...
defaults
mode http
option httplog
log-format frontend:%f/%H/%fi:%fp\ client:%ci:%cp\ GMT:%T\ body:%[capture.req.hdr(0)]\ request:%r
option dontlognull
# ...
frontend www-http
log global
option http-buffer-request
# id=0 to store body for logging
declare capture request len 40000
bind 7.7.7.7:8007
http-request capture req.body id 0
default_backend www-backend
backend www-backend
mode http
option forwardfor
# ...
我知道从 1.6.0 版开始可以使用 HAProxy 记录 POST 请求的主体。下面的mail archive表示我们需要以某种方式使用req.body并以日志格式记录capture.req.hdr。
上面提问的人 link 在他们的配置中有以下前端:
frontend www-http
bind 0.0.0.0:9000
option http-buffer-request
declare capture request len 400000
http-request capture req.body id 0
log-format {"%[capture.req.hdr(0)]"}
但大概这是错误的,因此他们的问题。
执行此操作的确切语法是什么?
自定义日志格式对我有用:
global
log 127.0.0.1 local0
debug
maxconn 2048
ulimit-n 8012
# ...
defaults
mode http
option httplog
log-format frontend:%f/%H/%fi:%fp\ client:%ci:%cp\ GMT:%T\ body:%[capture.req.hdr(0)]\ request:%r
option dontlognull
# ...
frontend www-http
log global
option http-buffer-request
# id=0 to store body for logging
declare capture request len 40000
bind 7.7.7.7:8007
http-request capture req.body id 0
default_backend www-backend
backend www-backend
mode http
option forwardfor
# ...