HAProxy 减慢来自特定 IP 的连接
HAProxy slow down connections from specific IP
有没有人知道使用 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
我的 tarpit 是不是我确实放慢了他们的速度,但并不像我最初想的那样。
在监听中创建限速table如下:
listen ratelimiting
mode http
stick-table type ip size 1m expire 1h store conn_rate(5000),conn_cur
非常感谢
我会在前端部分使用 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_backend
有没有人知道使用 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
我的 tarpit 是不是我确实放慢了他们的速度,但并不像我最初想的那样。
在监听中创建限速table如下:
listen ratelimiting
mode http
stick-table type ip size 1m expire 1h store conn_rate(5000),conn_cur
非常感谢
我会在前端部分使用 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_backend