@@ -328,6 +328,23 @@ backend be_tcp_{{$cfgIdx}}
328
328
timeout tunnel {{$value}}
329
329
{{ end }}
330
330
{{ 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
+
331
348
hash-type consistent
332
349
timeout check 5000ms
333
350
{{ range $serviceUnitName, $weight := $cfg.ServiceUnitNames }}
@@ -371,6 +388,28 @@ backend be_secure_{{$cfgIdx}}
371
388
{{ end }}
372
389
{{ end }}
373
390
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
+
374
413
timeout check 5000ms
375
414
http-request set-header X-Forwarded-Host %[req.hdr(host)]
376
415
http-request set-header X-Forwarded-Port %[dst_port]
0 commit comments