HAProxy community

HAProxy Ratelimit using stick table


#1

I wanted to achieve rate limiting based on certain rules.

  • I should have only one sticky table.
  • For each rule there should be one entry in the table.
  • Unique Key will be a CRC32 of (IP & URL)
  • If we get requests for same URL and from same IP, only then the counter should get incremented.
    So the key will be a combination of IP & Path.

Can someone help me in writing ACLs for the same ?

Also please let me know if this can achieved using lua.
Is there an api which we can use from lua, to increment the counter based on a unique key ?


#2

The haproxy blog has some excellent material covering both acls and stick tables https://www.haproxy.com/blog/category/basics/ and also ddos protection https://www.haproxy.com/blog/application-layer-ddos-attack-protection-with-haproxy/ where for sure you will find what you need.