HaProxy:如何记录响应正文
我能够捕获请求正文,但无法记录响应正文
我尝试了多个选项,但无法捕获响应正文。
HaProxy.cfg
global
log 127.0.0.1 local0
debug
maxconn 2000
user haproxy
group haproxy
defaults
log global
mode http
option httplog
option dontlognull
option http-keep-alive
timeout http-keep-alive 5m
timeout http-request 5s
timeout connect 10s
timeout client 300s
timeout server 300s
timeout check 2s
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
balance roundrobin
option httpchk
frontend LB
bind *:80
option httpclose
option forwardfor
option http-buffer-request
declare capture request len 400000
#declare capture response len 400000
#http-response capture res.header id 0
http-request capture req.body id 0
log-format "%ci:%cp-[%t]-%ft-%b/%s-[%Tw/%Tc/%Tt]-%B-%ts-%ac/%fc/%bc/%sc/%rc-%sq/%bq body:%[capture.req.hdr(0)]/ Response: %[capture.res(0)]"
monitor-uri /
#default_backend LB
# BEGIN YPS ACLs
acl is_yps path_beg /ems
use_backend LB if is_yps
# END YPS ACLs
backend LB
option httpchk GET /ems/login.html
server 10.164.29.225 10.164.30.50:8080 maxconn 300 check
server 10.164.27.31 10.164.30.50:8080 maxconn 300 check backup
答案 0 :(得分:1)
您可以通过在cfg文件中添加以下内容来记录正文
声明捕获请求行400000
HTTP请求捕获请求主体ID 0
日志127.0.0.1 len 65335 local0
无需更改日志格式,请使用默认的日志格式
答案 1 :(得分:0)
您无法记录请求/响应正文。看一下您可以记录的值:https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#8.2.4