Skip to content

Commit d9a3362

Browse files
committed
feat: apply sliding window rate limiting
1 parent a45ca9a commit d9a3362

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

salt/haproxy/config/haproxy.cfg.jinja

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ frontend main
117117
bind :::80
118118
bind 127.0.0.1:19001 # This is our TLS socket.
119119

120+
# Client rate limiting
121+
# See: https://www.haproxy.com/blog/four-examples-of-haproxy-rate-limiting
122+
stick-table type ip size 100k expire 15s store http_req_rate(10s)
123+
http-request track-sc0 src
124+
http-request deny deny_status 429 if { sc_http_req_rate(0) gt 20 }
125+
126+
# Do we need to whitelist the LBs?
127+
{# acl whitelist src 10.132.111.89 10.132.109.52 #}
128+
120129
# Custom logging format, this is the same as the normal "httplog" in
121130
# HAProxy except information about the TLS connection is included.
122131
log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %sslv/%sslc\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r

0 commit comments

Comments
 (0)