From bfda8eecd228a8b917675b97a8bc19a25a02e46f Mon Sep 17 00:00:00 2001 From: Sheppy Date: Tue, 10 Jan 2023 03:29:19 +0100 Subject: [PATCH] feat: support for extra locations --- templates/nginx_server_block.conf.j2 | 10 ++++++++++ vm.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/templates/nginx_server_block.conf.j2 b/templates/nginx_server_block.conf.j2 index 71c4d26..1ff1cdc 100644 --- a/templates/nginx_server_block.conf.j2 +++ b/templates/nginx_server_block.conf.j2 @@ -10,6 +10,16 @@ server{ {% if acme %} include acme-challenge.conf; {% endif %} + + {% if extra_location %} + location {{ extra_location["location"] }} { + {{ extra_location["content"] }} + {% if extra_location["location-auth"] %} + auth_basic "{{ extra_location["location-auth"] }}"; + auth_basic_user_file /etc/nginx/{{ extra_location["location-auth"] }}.htpasswd; + {% endif %} + } + {% endif %} location / { proxy_pass http://{{ targetip }}:{{ targetport }}; diff --git a/vm.py b/vm.py index 45241a2..c6f1e42 100644 --- a/vm.py +++ b/vm.py @@ -132,7 +132,8 @@ class VM: component = template.render(targetip=self.ip, targetport=targetport, servernames=[subdomain["name"]], comment=compositeName, proxy_pass_blob=self.proxy_pass_blob, acme=not self.noTerminateACME, - basicauth=subdomain.get("basicauth")) + basicauth=subdomain.get("basicauth"), + extra_location=subdomain.get("extra-location")) components.append(component) return components