mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-03-06 12:54:12 +01:00
Make matrix-synapse-reverse-proxy-companion not report "502 Bad Gateway" when Synapse workers restart
Since nginx 1.27.3, we can make use of the `resolve` parameter for an `upstream`'s `server`, to allow DNS resolution to happen continuously at runtime, not just once during startup. Previously, this was not possible to do in an `upstream` block without an nginx-plus subscription. Outside of an `upstream` block, we've used and still use `set $backend ..` workarounds to get DNS resolution at runtime, but now we can do it in `upstream` as well.
This commit is contained in:
parent
db993c5bb3
commit
1c68fd0d9b
@ -16,10 +16,18 @@
|
|||||||
{% macro render_worker_upstream(name, workers, load_balance) %}
|
{% macro render_worker_upstream(name, workers, load_balance) %}
|
||||||
{% if workers | length > 0 %}
|
{% if workers | length > 0 %}
|
||||||
upstream {{ name }} {
|
upstream {{ name }} {
|
||||||
|
{#
|
||||||
|
We need to use a zone so that the upstream is stored in shared memory,
|
||||||
|
otherwise we can't use `resolve` below, as reported by nginx:
|
||||||
|
> resolving names at run time requires upstream ".." in ... to be in shared memory
|
||||||
|
#}
|
||||||
|
zone {{ name }} 64k;
|
||||||
|
|
||||||
{{ load_balance }}
|
{{ load_balance }}
|
||||||
keepalive {{ ((workers | length) * 2) | string }};
|
keepalive {{ ((workers | length) * 2) | string }};
|
||||||
|
resolver {{ matrix_synapse_reverse_proxy_companion_http_level_resolver }} valid=5s;
|
||||||
{% for worker in workers %}
|
{% for worker in workers %}
|
||||||
server "{{ worker.name }}:{{ worker.port }}";
|
server "{{ worker.name }}:{{ worker.port }}" resolve;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user