Upstream servers must be in the virtualhost vars.

This commit is contained in:
Andrea Dell'Amico 2021-05-09 17:39:18 +02:00
parent 1f4510181e
commit 44ce326600
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
2 changed files with 8 additions and 6 deletions

View File

@ -103,10 +103,6 @@ nginx_logrotate_maxfilesize: "1G"
nginx_logrotate_retention: "52" nginx_logrotate_retention: "52"
nginx_use_common_virthost: False nginx_use_common_virthost: False
nginx_upstream_backends: []
# - name: unicorn
# servers:
# - 127.0.0.1:4000 fail_timeout=0
# #
# Virtualhost example # Virtualhost example
nginx_virthosts: [] nginx_virthosts: []
@ -115,6 +111,10 @@ nginx_virthosts: []
# server_name: '{{ ansible_fqdn }}' # server_name: '{{ ansible_fqdn }}'
# server_aliases: '' # server_aliases: ''
# index: index.html # index: index.html
# upstream_backends:
# - name: unicorn
# servers:
# - 127.0.0.1:4000 fail_timeout=0
# error_page: /path_to_error_page.html # error_page: /path_to_error_page.html
# ssl_enabled: False # ssl_enabled: False
# ssl_only: False # ssl_only: False

View File

@ -6,14 +6,16 @@ include /etc/nginx/snippets/nginx-websockets.conf;
{% endif %} {% endif %}
{% endif %} {% endif %}
{% for u_bk in nginx_upstream_backends %} {% if item.upstream_backends is defined %}
{% for u_bk in item.upstream_backends %}
upstream {{ u_bk.name }} { upstream {{ u_bk.name }} {
{% for srv in u_bk.servers %} {% for srv in u_bk.servers %}
server {{ u_bk.srv }}; server {{ srv }};
{% endfor %} {% endfor %}
} }
{% endfor %} {% endfor %}
{% endif %}
server { server {
listen {{ item.http_port | default ('80') }}; listen {{ item.http_port | default ('80') }};
server_name {{ item.server_name }} {% if item.serveraliases is defined %}{{ item.serveraliases }}{% endif %}; server_name {{ item.server_name }} {% if item.serveraliases is defined %}{{ item.serveraliases }}{% endif %};