Skip to content

Commit 43c0285

Browse files
BZ 1368050: add ability to change connection limits for reencrypt and passthrough routes
Extend the DDoS protection annotations from PR9810 to extend to reencrypt and passthrough routes https://bugzilla.redhat.com/show_bug.cgi?id=1368050
1 parent 9ab1f67 commit 43c0285

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

images/router/haproxy/conf/haproxy-config.template

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,23 @@ backend be_tcp_{{$cfgIdx}}
328328
timeout tunnel {{$value}}
329329
{{ end }}
330330
{{ end }}
331+
332+
{{ if matchPattern "true|TRUE" (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections") }}
333+
stick-table type ip size 100k expire 30s store conn_cur,conn_rate(3s),http_req_rate(10s)
334+
tcp-request content track-sc2 src
335+
{{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp")) }}
336+
tcp-request content reject if { src_conn_cur ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp" }} }
337+
{{ else }}
338+
# concurrent TCP connections not restricted
339+
{{ end }}
340+
341+
{{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp")) }}
342+
tcp-request content reject if { src_conn_rate ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp" }} }
343+
{{ else }}
344+
#TCP connection rate not restricted
345+
{{ end }}
346+
{{ end }}
347+
331348
hash-type consistent
332349
timeout check 5000ms
333350
{{ range $serviceUnitName, $weight := $cfg.ServiceUnitNames }}
@@ -371,6 +388,28 @@ backend be_secure_{{$cfgIdx}}
371388
{{ end }}
372389
{{ end }}
373390

391+
{{ if matchPattern "true|TRUE" (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections") }}
392+
stick-table type ip size 100k expire 30s store conn_cur,conn_rate(3s),http_req_rate(10s)
393+
tcp-request content track-sc2 src
394+
{{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp")) }}
395+
tcp-request content reject if { src_conn_cur ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp" }} }
396+
{{ else }}
397+
# concurrent TCP connections not restricted
398+
{{ end }}
399+
400+
{{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp")) }}
401+
tcp-request content reject if { src_conn_rate ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp" }} }
402+
{{ else }}
403+
#TCP connection rate not restricted
404+
{{ end }}
405+
406+
{{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-http")) }}
407+
tcp-request content reject if { src_http_req_rate ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-http" }} }
408+
{{ else }}
409+
#HTTP request rate not restricted
410+
{{ end }}
411+
{{ end }}
412+
374413
timeout check 5000ms
375414
http-request set-header X-Forwarded-Host %[req.hdr(host)]
376415
http-request set-header X-Forwarded-Port %[dst_port]

0 commit comments

Comments
 (0)