{%- if (item.ssl | default(true)) and not (item.allow_http | default(false)) %} server { listen {{ item.http_port | default(80) }}; listen [::]:{{ item.http_port | default(80) }}; server_name{% for domain_name in item.domain_names %} {{ domain_name }}{% endfor %}; return 301 https://$host$request_uri; } {% endif -%} server { {%- if item.ssl | default(true) %} listen {{ item.https_port | default(443) }} ssl http2; listen [::]:{{ item.https_port | default(443) }} ssl http2; {%- if item.allow_http | default(false) %} listen {{ item.http_port | default(80) }}; listen [::]:{{ item.http_port | default(80) }}; {%- endif %} {%- else %} listen {{ item.http_port | default(80) }}; listen [::]:{{ item.http_port | default(80) }}; {%- endif %} server_name{% for domain_name in item.domain_names %} {{ domain_name }}{% endfor %}; # Set proxy headers include {{ nginx_snippets_path }}/proxy-headers.conf; {%- if item.ssl | default(true) %} # SSL certificate and parameters ssl_certificate {{ item.ssl_certificate | default(nginx_ssl_certificate) }}; ssl_certificate_key {{ item.ssl_certificate_key | default(nginx_ssl_certificate_key) }}; include {{ nginx_snippets_path }}/ssl-params.conf; {%- endif %} {%- if item.websockets | default(false) %} # Enable websockets include {{ nginx_snippets_path }}/websockets.conf; {%- endif %} {%- if item.max_upload_size | default(false) %} # Max upload size client_max_body_size {{ item.max_upload_size }}; {%- endif %} {%- if item.extra_parameters | default(false) %} {{ item.extra_parameters }} {%- endif %} location / { proxy_pass {{ item.upstream_url }}; } }