Streams Basic Load Balancing (Allows multiple Forwarding Hosts)

This commit is contained in:
Guillaume Liautard
2022-04-14 01:10:28 +02:00
parent 4db34f5894
commit ec60004c96
9 changed files with 137 additions and 32 deletions

View File

@@ -3,6 +3,13 @@
# ------------------------------------------------------------
{% if enabled %}
upstream stream_{{ incoming_port }}_tcp {
{% for forwarding_host in forwarding_hosts %}
server {{ forwarding_host }}:{{ forwarding_port }};
{%- endfor %}
}
{% if tcp_forwarding == 1 or tcp_forwarding == true -%}
server {
listen {{ incoming_port }};
@@ -12,7 +19,7 @@ server {
#listen [::]:{{ incoming_port }};
{% endif %}
proxy_pass {{ forwarding_host }}:{{ forwarding_port }};
proxy_pass stream_{{ incoming_port }}_tcp;
# Custom
include /data/nginx/custom/server_stream[.]conf;
@@ -20,18 +27,26 @@ server {
}
{% endif %}
{% if udp_forwarding == 1 or udp_forwarding == true %}
upstream stream_{{ incoming_port }}_udp {
{% for forwarding_host in forwarding_hosts %}
server {{ forwarding_host }}:{{ forwarding_port }};
{%- endfor %}
}
server {
listen {{ incoming_port }} udp;
{% if ipv6 -%}
listen [::]:{{ incoming_port }} udp;
{% else -%}
#listen [::]:{{ incoming_port }} udp;
#listen [::]:{{ incoming_port }} udp;
{% endif %}
proxy_pass {{ forwarding_host }}:{{ forwarding_port }};
proxy_pass stream_{{ incoming_port }}_udp;
# Custom
include /data/nginx/custom/server_stream[.]conf;
include /data/nginx/custom/server_stream_udp[.]conf;
}
{% endif %}
{% endif %}
{% endif %}