add support to set location backends

This commit is contained in:
nd 2021-08-15 02:14:55 +02:00
parent 630a536c7f
commit fc5a1f4b2d
No known key found for this signature in database
GPG key ID: 21B5CD4DEE3670E9
2 changed files with 12 additions and 10 deletions

View file

@ -2,6 +2,7 @@
{% set vhost = {}|combine(nginx_vhosts_defaults, item.value, recursive=True) %}
{% set vhost_name = item.key %}
{% set vhost_headers = {}|combine(nginx.add_headers, vhost.add_headers) %}
{% set vhost_proxy_location = {}|combine(nginx_proxy_location, {'backend': vhost.backend }) if vhost.backend|d(False) else [] %}
{% macro nginx_listen(ips, port, options) %}
{% for ip in ips %}
@ -38,9 +39,13 @@ server {
{% endfor %}
{% if vhost.backend %}
location / {
proxy_pass {{ vhost.backend }};
{% for location in ( vhost.locations + vhost_proxy_location ) %}
location {{ location.match }} {
{% if "alias" in location %}
alias {{ location.alias }};
{% endif %}
{% if location.backend|d(False) %}
proxy_pass {{ location.backend }};
# add proxy headers
proxy_set_header Host {{ vhost.host }};
@ -72,13 +77,6 @@ server {
# no double headers
proxy_hide_header Strict-Transport-Security;
}
{% endif %}
{% for location in vhost.locations %}
location {{ location.match }} {
{% if "alias" in location %}
alias {{ location.alias }};
{% endif %}
{% for c in location.custom|default([]) %}
{{ c }};