From ba448f3185e4f5ceef5966708702673b60d864d2 Mon Sep 17 00:00:00 2001 From: nd Date: Mon, 11 Feb 2019 02:06:51 +0100 Subject: [PATCH] added location support --- README.md | 12 ++++++++++++ templates/vhost.j2 | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 0132016..b4333a8 100644 --- a/README.md +++ b/README.md @@ -62,5 +62,17 @@ backend: None # Set ssl certs to letsencrypt paths and enable letsencrypt for this vhost letsencrypt: False + +# array of locations, see below +locations: [*locationconfig*, .. ] +``` + +**locationconfig**: +``` +# a match definition, for example "/", see nginx docu: https://nginx.org/en/docs/http/ngx_http_core_module.html#location +match: '' + +# path, only set if not none +alias: None ``` diff --git a/templates/vhost.j2 b/templates/vhost.j2 index 01ba095..dfca497 100644 --- a/templates/vhost.j2 +++ b/templates/vhost.j2 @@ -16,6 +16,10 @@ server { listen [::]:{{ vhost_listen.nossl_port|default(80) }} ssl {% if vhost.default_server|default(False) %}default_server{% endif %}; {% endif %} + {% for header in vhost.add_headers|default([]) %} + add_header {{ header }} {{ vhost.add_headers[header] }}; + {% endfor %} + {% if vhost.backend|default(False) %} location / { proxy_pass {{ vhost.backend }}; @@ -36,6 +40,12 @@ server { } {% endif %} + {% for location in vhost.locations|default([]) %} + location {{ location.match }} { + {% if location.alias %}alias {{ location.alias }};{% endif %} + } + {% endfor %} + {% if vhost.letsencrypt|d(False) %} ssl_certificate /etc/ssl/letsencrypt_{{ vhost_name }}_chained.crt; ssl_certificate_key /etc/ssl/private/letsencrypt_{{ vhost_name }}.key;