Skip to content

Commit

Permalink
Add config snippet and 429.http file.
Browse files Browse the repository at this point in the history
The haproxy.cfg file contains just a snippet
to be modified and included in your own
HAProxy configuration.

The 429.http file can be used verbatim.
  • Loading branch information
dschneller committed Nov 30, 2014
1 parent fb3c173 commit f692fb4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 429.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
HTTP/1.1 429 Too Many Requests
Cache-Control: no-cache
Connection: close
Content-Type: text/plain
Retry-After: 60

Too Many Requests (HAP429).
24 changes: 24 additions & 0 deletions haproxy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
frontend fe_api_ssl
bind 192.168.0.1:443 ssl crt /etc/haproxy/ssl/api.pem no-sslv3 ciphers ...
default_backend be_api

tcp-request inspect-delay 5s

acl document_request path_beg -i /v2/documents
acl is_upload hdr_beg(Content-Type) -i multipart/form-data
acl too_many_uploads_by_user sc0_gpc0_rate() gt 100
acl mark_seen sc0_inc_gpc0 gt 0

stick-table type string size 100k store gpc0_rate(60s)

tcp-request content track-sc0 hdr(Authorization) if METH_POST document_request is_upload

use_backend 429_slow_down if too_many_uploads_by_user mark_seen

backend be_429_slow_down
timeout tarpit 2s
errorfile 500 /etc/haproxy/errorfiles/429.http
http-request tarpit

backend be_api
...

0 comments on commit f692fb4

Please sign in to comment.