Hello Sir,


down votefavorite
<http://stackoverflow.com/questions/39166887/haproxy-limiting-the-connection-rate-per-user#>

I am trying to achieve rate limiting using HAProxy. I am trying to follow
the "Limiting the connection rate per user" approach. I am able to achieve
this by the below configuration. But facing one problem, that is, i am not
able to send a custom error code once the rate limit is reached. For
example if i reached the rate limit i want to send HTTP error code 429. In
this case the proxy is simply rejecting the incoming call and users are
getting http status code as 0.Please let me know how can i do this

frontend localnodes

bind *:80
mode http
default_backend nodes

stick-table type ip size 100k expire 30s store conn_rate(5s)
tcp-request connection reject if { src_conn_rate ge 60 }
tcp-request connection track-sc1 src

backend nodes

cookie MYSRV insert indirect nocache
server srv1 <Server IP>:80 check cookie srv1 maxconn 500


Thanks
Samrat

Reply via email to