【问题标题】:HAProxy - Can I set a header on a monitor response?HAProxy - 我可以在监视器响应上设置标题吗?
【发布时间】:2018-02-23 14:44:28
【问题描述】:

我想在 HAProxy 监视器响应上设置自定义标头。这是我的测试配置文件:

defaults
  mode  http
  timeout  client  300000
  timeout  server  300000
  timeout connect 5000

listen header_test
  bind  :60001
  mode http
  no log
  monitor-uri /
  http-response set-header My-Header some-value

根据 1.8 documentationhttp-response listen 部分内受支持。但是,当我 GET / 使用此配置时,我看不到我的标题:

➜  ~ curl -v localhost:60001
* Rebuilt URL to: localhost:60001/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 60001 (#0)
> GET / HTTP/1.1
> Host: localhost:60001
> User-Agent: curl/7.54.0
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Cache-Control: no-cache
< Connection: close
< Content-Type: text/html
< 
<html><body><h1>200 OK</h1>
Service ready.
</body></html>
* Closing connection 0

我能够使用具有相同http-response 子句的常规前端/后端设置来查看标题。

在带有monitor-urilisten 部分中使用http-response 是否有效?如果没有,还有其他方法可以在监视器响应上设置标头吗?

使用 HAProxy 1.8.3:

➜  ~ haproxy -v
HA-Proxy version 1.8.3-205f675 2017/12/30
Copyright 2000-2017 Willy Tarreau <willy@haproxy.org>

【问题讨论】:

    标签: haproxy


    【解决方案1】:

    不,你不能。

    监控请求是在很早的阶段处理的,没有办法在监控请求的响应中添加标头。

    【讨论】:

    猜你喜欢
    • 2014-01-22
    • 2016-06-22
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 2020-01-02
    • 1970-01-01
    • 1970-01-01
    • 2012-09-07
    相关资源
    最近更新 更多