Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4849

Block IP if reach rate limit

$
0
0

Hi,
I have this configuration for rate limiting in HAproxy. I want to ensure that if a user hits the rate limit, their IP will be blocked for 5 minutes. Currently, in this configuration, if a user sends 200 requests in 10 seconds, they will reach the rate limit, but their IP will not be blocked. How can I modify it so that their IP gets blocked for 5 minutes when they reach the rate limit?

frontend front_api
    bind *:80
    timeout client 30s
    redirect scheme https if !{ ssl_fc }
    http-request set-header X-Forwarded-Proto https if { ssl_fc }
    mode http

    stick-table type ip size 1m expire 24h store http_req_rate(10s)
    tcp-request connection track-sc1 src
    http-request track-sc0 src table front_api
    acl exempt_ip src 10.0.0.19 10.0.0.4
    acl rate_limited src_http_req_rate(front_api) ge 200
    use_backend blocked_ips if rate_limited !exempt_ip

backend blocked_ips
    mode http
    http-request deny deny_status 429
    timeout client 300s

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>