我想在 HAProxy 中有一个限制规则来限制用户加载任何特定路径的速率,但我不知道在 HAProxy 中连接字符串的方法(至少,在为一个棍子 table )。所以我想要的是

tcp-request content track-sc1 concat(req.cook(user), path)
tcp-request content reject if {sc1_http_req_rate gt 10}

HAProxy manipulate string prior to map lookup 建议使用 regsub 做一些类似的事情,但我认为我只能用它来做不断的操作。

到目前为止,我想出的最好的方法是分别跟踪 pathreq.cook(user),如果它们中的每一个都太高,则拒绝,但这不是我正在寻找的实际行为。

最佳答案

您问题中的链接有答案。您先在 set-header 中进行连接,然后再使用它。

http-request set-header X-Concat %[req.cook(user)]__%[path]
http-request track-sc0 hdr(X-Concat) table peruser

关于haproxy - 在 HAProxy 中连接字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34825449/

10-16 09:16