是否有人知道如何使用HAProxy将传入的请求添加到到达的最大请求数量后再延迟,而不仅仅是拒绝或发送状态代码,实际上是对特定IP地址的请求进行排队,如果不是太多,则在数量减少后允许。
使用文档所有上述部分似乎都是可能的,尽管合并似乎是一个问题。
我的前端有以下内容:
#Add counter to ip in ratelimiting table
tcp-request content track-sc0 src table ratelimiting
# if alot of requests (more than 1000) - reject
acl mark_alot_of_requests sc0_conn_rate(ratelimiting) gt 1000
tcp-request content reject if mark_alot_of_requests TRUE
#If concurrent requests >= 100 from a single IP return 429
acl mark_too_many_requests sc0_conn_cur(ratelimiting) ge 100
use_backend 429_slow_down if mark_too_many_requests然后
backend 429_slow_down
mode http
timeout tarpit 5s
reqitarpit .
errorfile 500 /etc/haproxy/errors/429.http
http-request tarpit是我的讲坛,虽然我确实拖慢了他们,但并没有像我最初想的那样行事。
在“侦听”中创建了分级表,如下所示:
listen ratelimiting
mode http
stick-table type ip size 1m expire 1h store conn_rate(5000),conn_cur非常感谢
发布于 2017-05-06 14:45:49
我会在前端部分使用inspect-timeout和'WAIT_END`‘
frontend mywww
tcp-request content track-sc0 src table ratelimiting
acl mark_alot_of_requests sc0_conn_rate(ratelimiting) gt 1000
tcp-request content reject if mark_alot_of_requests TRUE
acl mark_too_many_requests sc0_conn_cur(ratelimiting) ge 100
# delay for request inspect, it will be used for effectively client delay
tcp-request inspect-delay 1000ms
# if client is not too fast let it through
tcp-request content accept unless mark_too_many_requests
# too fast clients, will need to wait entire inspect-delay
tcp-request content accept if WAIT_END
use_backend some_normal_backendhttps://stackoverflow.com/questions/43776786
复制相似问题