title: How to rate limit by HTTP status code with HAProxy?
body: <p>HAProxy provides a built-in <code>http_err_rate</code> counter which “reports the average HTTP request error rate over that period.” This can be used in a stick table to rate-limit clients that are generating a lot of errors. That might look something like this:</p>
  
  <pre><code>frontend web
    tcp-request content reject if { src_get_gpc0(Abuse) gt 0 }
    acl scanner src_http_err_rate(Abuse) ge 10
    http-request deny if scanner flag_abuser
  
  backend Abuse
    stick-table type ip size 1m expire 60m store gpc0,http_err_rate(20s)
  </code></pre>
  
  <p>What I'd like to do is track something like the <code>http_err_rate</code>, but only for <code>401 Unauthorized</code> status codes. That way HAProxy would only be concerned with rate-limiting unauthorized requests, rather than all HTTP error codes.</p>
  
  <p>Thanks!</p>