diff options
-rw-r--r-- | chaos-at-home/ch-http-proxy.yml | 6 | ||||
-rw-r--r-- | roles/nginx/vhost/defaults/main.yml | 14 | ||||
-rw-r--r-- | roles/nginx/vhost/templates/static-files-with-acme.conf.j2 | 30 | ||||
-rw-r--r-- | spreadspace/glt-stream.yml | 20 |
4 files changed, 42 insertions, 28 deletions
diff --git a/chaos-at-home/ch-http-proxy.yml b/chaos-at-home/ch-http-proxy.yml index 79ed31d5..2b410433 100644 --- a/chaos-at-home/ch-http-proxy.yml +++ b/chaos-at-home/ch-http-proxy.yml @@ -46,8 +46,10 @@ acme: yes hostnames: - web.chaos-at-home.org - root: /var/www/default - index: index.html + locations: + '/': + root: /var/www/default + index: index.html acmetool_cert_config: request: challenge: diff --git a/roles/nginx/vhost/defaults/main.yml b/roles/nginx/vhost/defaults/main.yml index 18c9a0b9..06f3dfb5 100644 --- a/roles/nginx/vhost/defaults/main.yml +++ b/roles/nginx/vhost/defaults/main.yml @@ -27,7 +27,13 @@ # acme: yes # hostnames: # - static.example.com -# root: /srv/www/static -# index: index.html -# autoindex: -# format: json +# extra_directives: |- +# add_header X-Example-Header "foo"; +# locations: +# '/': +# root: /srv/www/static +# index: index.html +# autoindex: +# format: json +# extra_directives: |- +# add_header X-Example-Header "foo"; 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 %} } diff --git a/spreadspace/glt-stream.yml b/spreadspace/glt-stream.yml index 3a897377..9ce0d4e6 100644 --- a/spreadspace/glt-stream.yml +++ b/spreadspace/glt-stream.yml @@ -43,13 +43,17 @@ acme: yes hostnames: - stream.linuxtage.at - root: /srv/www/stream - index: index.html - directives_extra: - server: |- - add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer"; - add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS"; - add_header Access-Control-Allow-Origin "*"; - add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range,Date"; + extra_directives: |- + add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer"; + add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS"; + add_header Access-Control-Allow-Origin "*"; + add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range,Date"; + locations: + '/': + root: /srv/www/stream + index: index.html + '/preped': + root: /srv/www/stream + autoindex: {} include_role: name: nginx/vhost |