@@ -339,6 +339,23 @@ backend be_tcp_{{$cfgIdx}}
339
339
timeout tunnel {{$value}}
340
340
{{ end }}
341
341
{{ end }}
342
+
343
+ {{ if matchPattern "true|TRUE" (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections") }}
344
+ stick-table type ip size 100k expire 30s store conn_cur,conn_rate(3s),http_req_rate(10s)
345
+ tcp-request content track-sc2 src
346
+ {{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp")) }}
347
+ tcp-request content reject if { src_conn_cur ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp" }} }
348
+ {{ else }}
349
+ # concurrent TCP connections not restricted
350
+ {{ end }}
351
+
352
+ {{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp")) }}
353
+ tcp-request content reject if { src_conn_rate ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp" }} }
354
+ {{ else }}
355
+ #TCP connection rate not restricted
356
+ {{ end }}
357
+ {{ end }}
358
+
342
359
hash-type consistent
343
360
timeout check 5000ms
344
361
{{ range $serviceUnitName, $weight := $cfg.ServiceUnitNames }}
@@ -386,6 +403,28 @@ backend be_secure_{{$cfgIdx}}
386
403
{{ end }}
387
404
{{ end }}
388
405
406
+ {{ if matchPattern "true|TRUE" (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections") }}
407
+ stick-table type ip size 100k expire 30s store conn_cur,conn_rate(3s),http_req_rate(10s)
408
+ tcp-request content track-sc2 src
409
+ {{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp")) }}
410
+ tcp-request content reject if { src_conn_cur ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp" }} }
411
+ {{ else }}
412
+ # concurrent TCP connections not restricted
413
+ {{ end }}
414
+
415
+ {{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp")) }}
416
+ tcp-request content reject if { src_conn_rate ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-tcp" }} }
417
+ {{ else }}
418
+ #TCP connection rate not restricted
419
+ {{ end }}
420
+
421
+ {{ if (isInteger (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-http")) }}
422
+ tcp-request content reject if { src_http_req_rate ge {{ index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections.rate-http" }} }
423
+ {{ else }}
424
+ #HTTP request rate not restricted
425
+ {{ end }}
426
+ {{ end }}
427
+
389
428
timeout check 5000ms
390
429
http-request set-header X-Forwarded-Host %[req.hdr(host)]
391
430
http-request set-header X-Forwarded-Port %[dst_port]
0 commit comments