将 regex/wildcard 与 haproxy 中的 http header NAMES 匹配
Match regex/wildcard against http header NAMES in haproxy
我想添加一个 acl 规则来捕获匹配以下正则表达式的 header name 的存在:^X-\w+-Signature
(或其他任何内容)通配符)。要匹配的示例:
X-Abc-Signature
X-Whatever-Signature
X-Service-Signature
我知道我可以明确地创建如下规则:
acl has_abc_token req.fhdr(X-Abc-Signature) -m found
acl has_whatever_token req.fhdr(X-Whatever-Signature) -m found
acl has_service_token req.fhdr(X-Service-Signature) -m found
甚至可以在 haproxy 中执行此操作吗?
另外,我的理解是haproxy中的\w
字符classdoes not exist?
看起来 req.hdr_names()
可能 是我要找的东西,但我不知道如何使用它。
没关系。我想通了:
acl has_sig req.hdr_names() -m reg -i ,X-[A-Za-z]+-Signature
我想添加一个 acl 规则来捕获匹配以下正则表达式的 header name 的存在:^X-\w+-Signature
(或其他任何内容)通配符)。要匹配的示例:
X-Abc-Signature
X-Whatever-Signature
X-Service-Signature
我知道我可以明确地创建如下规则:
acl has_abc_token req.fhdr(X-Abc-Signature) -m found
acl has_whatever_token req.fhdr(X-Whatever-Signature) -m found
acl has_service_token req.fhdr(X-Service-Signature) -m found
甚至可以在 haproxy 中执行此操作吗?
另外,我的理解是haproxy中的\w
字符classdoes not exist?
看起来 req.hdr_names()
可能 是我要找的东西,但我不知道如何使用它。
没关系。我想通了:
acl has_sig req.hdr_names() -m reg -i ,X-[A-Za-z]+-Signature