diff --git a/templates/nginx-virthost.j2 b/templates/nginx-virthost.j2
index 73703a2..15a849e 100644
--- a/templates/nginx-virthost.j2
+++ b/templates/nginx-virthost.j2
@@ -144,6 +144,7 @@ server {
     {% else %}
     include /etc/nginx/snippets/nginx-proxy-params.conf;
     {% endif %}
+    {% endif %}
 
     {% if item.locations is defined %}
     {% for location in item.locations -%}
@@ -319,6 +320,7 @@ server {
     {% else %}
     include /etc/nginx/snippets/nginx-proxy-params.conf;
     {% endif %}
+    {% endif %}
 
     {% if item.locations is defined %}
     {% for location in item.locations -%}