【问题标题】:HAProxy add header based on URL parameterHAProxy 根据 URL 参数添加标头
【发布时间】:2019-08-21 15:54:12
【问题描述】:

使用HAProxy v1.6

我正在处理当前(至少在 javascript 上)不支持自定义标头的 Websocket 请求。

我正在尝试基于 get 参数在 HAProxy 层添加自定义标头(在将其转发到负载均衡器之前)

例子:

下一个代码有效(在后端)

#match get-url someGetKey paramater
acl is_key_match        url_reg          \?(?:.*?)someGetKey=([\w|=]+)
#Add header
http-request set-header My-Custom-Header hardcoded_string if is_key_match

我的目标是将hardcoded_string替换为正则表达式\?(?:.*?)someGetKey=([\w|=]+)的第一个匹配组

有可能吗?

谢谢!

【问题讨论】:

    标签: load-balancing haproxy


    【解决方案1】:

    找到解决方案:

    http-request set-header cookie %[urlp(SSession)] if is_sticky_url
    

    %[] - 变量
    url(SSession) - 带有密钥 SSession 的 HTTP-GET 参数

    例如,网址:

    https://www.example.com/path?sSession=abcd
    

    将转发带有标头的请求:

    cookie=abcd
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      • 2018-10-17
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      相关资源
      最近更新 更多