nginx/site: Allow using url format for multiple proxies

This commit is contained in:
Timo Makinen 2022-07-10 14:46:56 +00:00
parent 5f8371eb12
commit 6f12feebc3

View file

@ -1,6 +1,7 @@
{% if proxy is defined and proxy is not string %}
upstream upstream_{{ site }} {
{% for item in proxy %}
{% set item = item | regex_replace("^(https://)?([^/]*).*$", "\\2") %}
{% if item | regex_search(".*:[0-9]+$") %}
server {{ item }};
{% else %}
@ -35,9 +36,10 @@ server {
{% elif proxy is defined %}
location / {
{% if proxy is not string %}
{% set path = proxy[0] | regex_replace("^(https://)?([^/]*)(.*)$", "\\3") %}
# https://trac.nginx.org/nginx/ticket/1307
proxy_ssl_verify off;
proxy_pass https://upstream_{{ site }};
proxy_pass https://upstream_{{ site }}{{ path }};
{% else %}
proxy_pass {{ proxy }};
{% endif %}