From d007b5c8a4c7287753cc640e2ccfd4f1d68ad1fd Mon Sep 17 00:00:00 2001 From: Teagan Glenn Date: Sat, 29 Jun 2024 20:45:05 -0600 Subject: [PATCH] feat(streams): Add least connection and max_fails if hosts > 1 --- backend/templates/stream.conf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/templates/stream.conf b/backend/templates/stream.conf index c7848223..6c328c14 100644 --- a/backend/templates/stream.conf +++ b/backend/templates/stream.conf @@ -5,8 +5,16 @@ {% if enabled %} upstream stream_{{ incoming_port }}_tcp { + {% if forwarding_hosts.length > 1 -%} + least_conn; + {%- endif -%} + {% for forwarding_host in forwarding_hosts %} + {% if forloop.first == true and forloop.last == true -%} server {{ forwarding_host }}:{{ forwarding_port }}; + {%- else -%} + server {{ forwarding_host}}:{{ forwarding_port}} max_fails=3; + {%- endif %} {%- endfor %} }