Merge "Enable uwsgi to bind to multiple different IP addresses"

This commit is contained in:
Zuul 2022-12-30 19:56:28 +00:00 committed by Gerrit Code Review
commit cd49d19055
3 changed files with 18 additions and 4 deletions

View File

@ -48,7 +48,7 @@ uwsgi_env: "{{ _uwsgi_env }}"
# uwsgi_overrides: {}
# uwsgi_processes: [ansible_facts['processor_vcpus'] | default(1), 1] | max * 2
# uwsgi_threads: 1
# uwsgi_bind_address: 0.0.0.0
# uwsgi_bind_address: 0.0.0.0 # OR a list, uwsgi_bind_address: [ '127.0.0.1', '1.2.3.4' ]
# uwsgi_port: 8080
# uwsgi_env: "FOO=bar"
# uwsgi_tls:

View File

@ -0,0 +1,7 @@
---
features:
- |
The variable ``uwsgi_bind_address`` can now be a single IP address
passed as a string, or a list of IP addresses passed in a yaml list
to the uwsgi role. This allows uwsgi to listen on a specific set of
IP addresses rather than just a single one.

View File

@ -13,11 +13,18 @@ wsgi-file = {{ item.value.wsgi_path }}
{% elif 'wsgi' in item.value %}
wsgi = {{ item.value.wsgi }}
{% endif %}
{% if item.value.uwsgi_tls | default({}) | length %}
https-socket = {{ item.value.uwsgi_bind_address | default('0.0.0.0') }}:{{ item.value.uwsgi_port | default(8080) }},{{ item.value.uwsgi_tls.crt }},{{ item.value.uwsgi_tls.key }},HIGH
{% if (item.value.uwsgi_bind_address is defined) and (item.value.uwsgi_bind_address is not string) and (item.value.uwsgi_bind_address is iterable) %}
{% set addresses = item.value.uwsgi_bind_address %}
{% else %}
http-socket = {{ item.value.uwsgi_bind_address | default('0.0.0.0') }}:{{ item.value.uwsgi_port | default(8080) }}
{% set addresses = [item.value.uwsgi_bind_address | default('0.0.0.0')] %}
{% endif %}
{% for addr in addresses %}
{% if item.value.uwsgi_tls | default({}) | length %}
https-socket = {{ addr }}:{{ item.value.uwsgi_port | default(8080) }},{{ item.value.uwsgi_tls.crt }},{{ item.value.uwsgi_tls.key }},HIGH
{% else %}
http-socket = {{ addr }}:{{ item.value.uwsgi_port | default(8080) }}
{% endif %}
{% endfor %}
master = true
enable-threads = true