From ba22f409ff1f780681801c91170704408fe81777 Mon Sep 17 00:00:00 2001 From: nrb <freifunk@nicoboehr.de> Date: Sun, 10 Jan 2021 10:49:07 +0100 Subject: [PATCH] revproxy: add redirect support --- host_vars/revproxy-05.freifunk-stuttgart.de/revproxy | 2 +- roles/revproxy/templates/vhosts.conf | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/host_vars/revproxy-05.freifunk-stuttgart.de/revproxy b/host_vars/revproxy-05.freifunk-stuttgart.de/revproxy index fa35234..08f96ad 100644 --- a/host_vars/revproxy-05.freifunk-stuttgart.de/revproxy +++ b/host_vars/revproxy-05.freifunk-stuttgart.de/revproxy @@ -4,6 +4,6 @@ letsencrypt_acme_directory: "https://acme-v02.api.letsencrypt.org/directory" vhosts: - domain: grafana.freifunk-stuttgart.de backend: http://10.0.3.237/ - type: https + type: proxy enabled: true diff --git a/roles/revproxy/templates/vhosts.conf b/roles/revproxy/templates/vhosts.conf index e76b568..75e149b 100644 --- a/roles/revproxy/templates/vhosts.conf +++ b/roles/revproxy/templates/vhosts.conf @@ -27,6 +27,7 @@ server { } location / { +{% if vhost.type == "proxy" %} proxy_pass {{ vhost.backend }}; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $ip_anonymized; @@ -39,6 +40,9 @@ server { proxy_pass_header Authorization; proxy_read_timeout 600s; proxy_request_buffering off; +{% elif vhost.type == "redirect" %} + return 301 {{ vhost.redirect }}$request_uri; +{% endif %} } } @@ -47,7 +51,11 @@ server { server_name {{ vhost.domain}}; location / { +{% if vhost.type == "proxy" %} return 301 https://{{ vhost.domain }}$request_uri; +{% elif vhost.type == "redirect" %} + return 301 {{ vhost.redirect }}$request_uri; +{% endif %} } # lets encrypt challenges -- GitLab