使用 HAProxy - Lua 管理粘性表以进行速率限制是否可能?

我正在使用 HAProxy 作为负载均衡器,我有一个 lua 脚本,它返回后端名称到 haproxy.cfg。想要实现我的应用程序的速率限制。

我知道我们可以使用另外的粘性表 (如下所示) 在 haproxy.cfg 中实现速率限制。


stick-table 类型 ip 大小 1m 过期 60s 存储 http_req_cnt

acl exceeds_limit hdr_ip(x-forwarded-for,-1),table_http_req_cnt(incoming) ge 10

http-request tarpit if exceeds_limit

http-request track-sc0 hdr_ip(x-forwarded-for,-1)


想使用 lua 实现相同的操作。是可能使用 lua 访问该粘性表吗?

提前感谢。

点赞