diff --git a/host_vars/revproxy-05.freifunk-stuttgart.de/revproxy b/host_vars/revproxy-05.freifunk-stuttgart.de/revproxy index fa352348e9808d4521d9bea818f7f74fee7a1a3e..08f96ad3fd413d9b7a64e3f76834e45974a373b5 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 e76b568ae8b65f559ed735ef2d163ffb1a3b2501..75e149b5369fad01d06b595a110da4075c0ffba5 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