2015-11-26 39 views
2

據我所知,可以使用HAProxy從版本1.6.0開始記錄POST請求的BODY。以下mail archive表示我們需要以某種方式使用req.body並以日誌格式記錄capture.req.hdr。將HAProxy配置爲日誌請求BODY

要求在上面的鏈接的人有下列前端在其配置:

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)]"} 

但據推測這是錯誤的,因此他們的問題。

這是什麼確切的語法?

回答

2

這個工作對我的自定義日誌格式:

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 
# ...