问题原文
原帖链接 · Peter Groves · CC BY-SA 3.0
I'm trying to track down some problems with the way a javascript client is interacting with an application server and would like to see the entire http payload (headers, body, and everything) that is being passed back and forth.
It so happens that there is already an haproxy server in front of the application server, so I was hoping to be able to use haproxy to provide the relevant logs. Obviously this would be bad to turn on in production, but I have a clone of the entire environment that can be isolated while I do this debugging.
Is there a way to get haproxy to log the entire http payload for POST requests going to a particular backend server?
社区高分解答
原帖链接 · hack_on · CC BY-SA 3.0
Apparently since version 1.6.0 (October 2015) you can now. There is a new directive:
option http-buffer-request
That you include in the front-end or back-end to give HAProxy access to the body. And you use req.body to access it. Here is a summary of the config I used:
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\ 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
# ...
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
