add support for defining multiple upstream servers for proxy sites

This commit is contained in:
Timo Makinen 2019-06-06 01:56:00 +03:00
parent 11e4a82a35
commit b533542b57

View file

@ -1,4 +1,10 @@
{% if proxy is defined and proxy is not string %}
upstream upstream_{{ site }} {
{% for item in proxy %}
server {{ item }}:443;
{% endfor %}
}
{% endif %}
server {
listen 443 ssl;
listen [::]:443 ssl;
@ -11,7 +17,11 @@ server {
return 301 {{ redirect }};
{% elif proxy is defined %}
location / {
{% if proxy is not string %}
proxy_pass https://upstream_{{ site }};
{% else %}
proxy_pass {{ proxy }};
{% endif %}
proxy_ssl_certificate {{ tls_certs }}/{{ inventory_hostname }}.crt;
proxy_ssl_certificate_key {{ tls_private }}/{{ inventory_hostname }}.key;
}