Skip to content

Commit 33f72ee

Browse files
committed
Allow to generate custom locations in load_balancer mode
1 parent 63126c3 commit 33f72ee

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

defaults/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ nginx_http_template:
168168
html_file_name: index.html
169169
http_demo_conf: false
170170
load_balancer:
171-
proxy_pass: backend
171+
locations:
172+
backend:
173+
location: /
174+
proxy_pass: backend
172175
health_check_plus: false
173176
upstreams:
174177
upstream1:

templates/http/default.conf.j2

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ server {
2424
{% endif %}
2525
server_name {{ item.value.server_name }};
2626
{% if item.value.load_balancer is defined %}
27-
location / {
28-
proxy_pass http://{{ item.value.load_balancer.proxy_pass }};
27+
{% for location in item.value.load_balancer.locations %}
28+
location {{ item.value.load_balancer.locations[location].location }} {
29+
proxy_pass http://{{ item.value.load_balancer.locations[location].proxy_pass }};
2930
{% if item.value.load_balancer.health_check_plus %}
3031
health_check;
3132
{% endif %}
@@ -34,6 +35,8 @@ server {
3435
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3536
proxy_set_header X-Forwarded-Proto $scheme;
3637
}
38+
39+
{% endfor %}
3740
{% endif %}
3841
{% if item.value.web_server is defined %}
3942
location / {

0 commit comments

Comments
 (0)