{%- from "__nginx.jinja2" import upstream, server, listen, server_name, proxy_pass, include -%}
{% for ups in upstreams -%}
{{ upstream(ups.name, *ups.servers) }}
{%- endfor %}

{% for s in servers -%}
{%- call server() -%}
{% for l in s.listens -%}
{{ listen(l.0, l.1, l.2) }}
{%- endfor %}
{{ proxy_pass(proxy_pass=s.name, protocol="tcp") }}
{{ include(s.name) }}
{%- endcall %}
{% endfor %}
