It is possible to limit the number of request in HAProxy by using almost any gathered data.
This topic is huge and complexe as it is possible to make everything, depending the needs.
A good introduction can be found on the blog of
haproxy.com.
I have a simple cas where I only want to block an IP if the number of requests if too hight.
In a frontend
:
stick-table type ip size 1m expire 10s store conn_rate(10s)
tcp-request inspect-delay 10s
tcp-request content track-sc0 src
tcp-request content reject if { sc_conn_rate(0) gt 10 }
Explications:
sc0
to follow the source IP (the counter is automatically linked to the previous table as
it is in the same frontend)