Allow to generate custom locations in load_balancer mode

This commit is contained in:
Alexander Rublev 2018-11-13 09:57:44 +03:00
parent 63126c3ff7
commit 33f72ee8f2
2 changed files with 9 additions and 3 deletions

View File

@ -168,7 +168,10 @@ nginx_http_template:
html_file_name: index.html html_file_name: index.html
http_demo_conf: false http_demo_conf: false
load_balancer: load_balancer:
proxy_pass: backend locations:
backend:
location: /
proxy_pass: backend
health_check_plus: false health_check_plus: false
upstreams: upstreams:
upstream1: upstream1:

View File

@ -24,8 +24,9 @@ server {
{% endif %} {% endif %}
server_name {{ item.value.server_name }}; server_name {{ item.value.server_name }};
{% if item.value.load_balancer is defined %} {% if item.value.load_balancer is defined %}
location / { {% for location in item.value.load_balancer.locations %}
proxy_pass http://{{ item.value.load_balancer.proxy_pass }}; location {{ item.value.load_balancer.locations[location].location }} {
proxy_pass http://{{ item.value.load_balancer.locations[location].proxy_pass }};
{% if item.value.load_balancer.health_check_plus %} {% if item.value.load_balancer.health_check_plus %}
health_check; health_check;
{% endif %} {% endif %}
@ -34,6 +35,8 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
{% endfor %}
{% endif %} {% endif %}
{% if item.value.web_server is defined %} {% if item.value.web_server is defined %}
location / { location / {