File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,6 @@ global
5252 # Lower the amount of space we reserve for header rewriting
5353 tune.maxrewrite 1024
5454
55- # rate limits only if there is a rate_limit in haproxy.sls
56- {% for service , config in haproxy .services .items () %}
57- {% if config .get ('rate_limit' ) %}
58- stick-table type ip size 100k expire 30s store http_req_rate(1s) name {{ service }}_ratelimit
59- {% endif %}
60- {% endfor %}
61-
6255defaults
6356 log global
6457
@@ -125,9 +118,16 @@ frontend main
125118
126119 # Apply rate limits per srvice
127120 {% for service , config in haproxy .services .items () %}
128- {% if config .get ('rate_limit' ) %}
121+ {% if config .get ('rate_limit' ) and loop .index <= 2 %}
122+ stick-table type ip size 100k expire 30s store http_req_rate(1s)
123+ {% endif %}
124+ {% endfor %}
125+
126+ # Apply rate limits
127+ {% for service , config in haproxy .services .items () %}
128+ {% if config .get ('rate_limit' ) and loop .index <= 2 %}
129129 acl is_{{ service }} hdr(host) -i {% for domain in config .domains %} {{ domain }} {% endfor %}
130- http-request track-sc{{ loop.index }} src table {{ service }}_ratelimit if is_{{ service }}
130+ http-request track-sc{{ loop.index }} src if is_{{ service }}
131131 http-request deny deny_status 429 if is_{{ service }} { sc{{ loop.index }}_http_req_rate() gt {{ config.rate_limit }} }
132132 {% endif %}
133133 {% endfor %}
You can’t perform that action at this time.
0 commit comments