【问题标题】:Haproxy - cannot capture URLHaproxy - 无法捕获 URL
【发布时间】:2018-04-25 11:34:45
【问题描述】:

最近我开始使用 haproxy 作为负载平衡器,并希望同时捕获 URL 和帖子正文。我成功捕获了帖子数据,但找不到同时捕获 URL 的解决方案。

haproxy.cfg:

frontend main
  log global
  option http-buffer-request
  declare capture request len 400000
  http-request capture req.body id 0
  log-format {"%[capture.req.hdr(0)]"}
  mode http
  bind *:5000

输入:

wget http://test.com:5000/ --post-data="THIS_IS_A_TEST"

输出:

[root@testhaproxy01 ~]# tail /var/log/haproxy/haproxy.log
Apr 25 11:16:17 test.com haproxy[17061]: {THIS_IS_A_TEST}
Apr 25 11:16:17 test.com haproxy[17061]: {THIS_IS_A_TEST}

我怎样才能捕获http://test.com:5000/

我使用的是 haproxy 1.8.7 版。

【问题讨论】:

    标签: centos7 haproxy


    【解决方案1】:

    你可以用这个

     capture request  header Host len 20
     log-format  "%[capture.req.hdr(1)]%HU ==> {%[capture.req.hdr(0)]}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-31
      • 1970-01-01
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多