diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 8051616..bfd34e4 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -7,7 +7,6 @@ server { {% else %} listen 80; listen [::]:80; - {% endif %} {% if proxy_protocol is defined %} listen 81 proxy_protocol; @@ -22,6 +21,7 @@ server { port_in_redirect off; {% endif %} + {% endif %} server_name {{ domains | join(' ') }}; location / { @@ -45,8 +45,6 @@ server { {% else %} listen 443 ssl http2; listen [::]:443 ssl http2; - {% endif %} - server_name {% if redirect_to_first is not defined or not redirect_to_first %}{{ domains | join(' ') }}{% else %}{{ domains[0] }}{% endif %}; {% if proxy_protocol is defined %} listen 442 ssl http2 proxy_protocol; @@ -61,6 +59,8 @@ server { port_in_redirect off; {% endif %} + {% endif %} + server_name {% if redirect_to_first is not defined or not redirect_to_first %}{{ domains | join(' ') }}{% else %}{{ domains[0] }}{% endif %}; {% if ssl_certificate is defined -%} {{ ssl_certificate | indent(4) }} @@ -87,8 +87,6 @@ server { {% else %} listen 443 ssl http2; listen [::]:443 ssl http2; - {% endif %} - server_name {{ domains[1:] | join(' ') }}; {% if proxy_protocol is defined %} listen 442 ssl http2 proxy_protocol; @@ -103,6 +101,8 @@ server { port_in_redirect off; {% endif %} + {% endif %} + server_name {{ domains[1:] | join(' ') }}; {% if ssl_certificate is defined %} {{ ssl_certificate }}