Configuration 根据查询字符串替换响应头的Haproxy前端配置

Configuration 根据查询字符串替换响应头的Haproxy前端配置,configuration,load-balancing,haproxy,Configuration,Load Balancing,Haproxy,我在前端使用了以下haproxy配置,根据查询字符串修改请求的响应头: frontend my-frontend acl is-foo urlp(foo) 1 http-response replace-header Set-Cookie "(.*)" "\1; SameSite=None" if is-foo 根据我在文档中的信息,acl应该匹配所有请求,如 example.com?a=b&foo=1&bar=2 examp

我在前端使用了以下haproxy配置,根据查询字符串修改请求的响应头:

frontend my-frontend
   acl is-foo urlp(foo) 1
   http-response replace-header Set-Cookie "(.*)" "\1; SameSite=None" if is-foo
根据我在文档中的信息,acl应该匹配所有请求,如

example.com?a=b&foo=1&bar=2
example.com?foo=1
example.com?a=b&foo=1
example.com?a=b&foo=0&bar=2
example.com?a=b
example.com?a=b&foo=bar
而且它不应该与这样的请求匹配

example.com?a=b&foo=1&bar=2
example.com?foo=1
example.com?a=b&foo=1
example.com?a=b&foo=0&bar=2
example.com?a=b
example.com?a=b&foo=bar
实际结果是acl从不匹配。 如果我反转
If
即:
If!is foo
每次请求都会发生替换头。 所以问题一定是acl,它从不匹配


我使用haproxy 2.0.15

我自己让它工作

当执行http响应时,
urlp(foo)
似乎在运行时不存在

因此,我们需要在之前使用
setvar(custom.name)
将其值存储在临时变量中。在if条件下运行时,我们可以使用
var(custom.name)
访问它,并将其与我们的条件匹配。我在这里使用了
urlp\u val()
而不是
urlp()
,因为值将立即转换为int

frontend my-frontend
    http-request set-var(txn.foo) urlp_val(foo)
    http-response replace-header Set-Cookie "(.*)" "\1; SameSite=None" if { var(txn.foo) eq 1 }
谢谢你的旅行