From 0cc14f6472bd45e6fbe1bd2a058da3eb58c5c923 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 3 Apr 2021 19:29:46 +0200 Subject: nginx/vhost make static file templatemore generic --- .../vhost/templates/static-files-with-acme.conf.j2 | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'roles/nginx/vhost/templates/static-files-with-acme.conf.j2') diff --git a/roles/nginx/vhost/templates/static-files-with-acme.conf.j2 b/roles/nginx/vhost/templates/static-files-with-acme.conf.j2 index 3dec7f27..09f22544 100644 --- a/roles/nginx/vhost/templates/static-files-with-acme.conf.j2 +++ b/roles/nginx/vhost/templates/static-files-with-acme.conf.j2 @@ -21,24 +21,26 @@ server { ssl_certificate_key /var/lib/acme/live/{{ nginx_vhost.hostnames[0] }}/privkey; include snippets/hsts.conf; -{% if 'directives_extra' in nginx_vhost and 'server' in nginx_vhost.directives_extra %} - {{ nginx_vhost.directives_extra.server | indent(4) }} +{% if 'extra_directives' in nginx_vhost %} + {{ nginx_vhost.extra_directives | indent(4) }} {% endif %} - location / { - root {{ nginx_vhost.root }}; -{% if 'index' in nginx_vhost %} - index {{ nginx_vhost.index }}; -{% endif %} -{% if 'autoindex' in nginx_vhost %} +{% for path, location in nginx_vhost.locations.items() %} + location {{ path }} { + root {{ location.root }}; +{% if 'index' in location %} + index {{ location.index }}; +{% endif %} +{% if 'autoindex' in location %} autoindex on; -{% if 'format' in nginx_vhost.autoindex %} +{% if 'format' in location.autoindex %} autoindex_format {{ nginx_vhost.autoindex.format }}; -{% endif %} -{% endif %} -{% if 'directives_extra' in nginx_vhost and 'location' in nginx_vhost.directives_extra %} +{% endif %} +{% endif %} +{% if 'extra_directives' in location %} - {{ nginx_vhost.directives_extra.location | indent(8) }} -{% endif %} + {{ location.extra_directives | indent(8) }} +{% endif %} } +{% endfor %} } -- cgit v1.2.3