feat(streams): Add least connection and max_fails if hosts > 1

This commit is contained in:
Teagan Glenn 2024-06-29 20:45:05 -06:00 committed by GitHub
parent 32fb98fb7c
commit d007b5c8a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,8 +5,16 @@
{% if enabled %} {% if enabled %}
upstream stream_{{ incoming_port }}_tcp { upstream stream_{{ incoming_port }}_tcp {
{% if forwarding_hosts.length > 1 -%}
least_conn;
{%- endif -%}
{% for forwarding_host in forwarding_hosts %} {% for forwarding_host in forwarding_hosts %}
{% if forloop.first == true and forloop.last == true -%}
server {{ forwarding_host }}:{{ forwarding_port }}; server {{ forwarding_host }}:{{ forwarding_port }};
{%- else -%}
server {{ forwarding_host}}:{{ forwarding_port}} max_fails=3;
{%- endif %}
{%- endfor %} {%- endfor %}
} }