Browse Source

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.
pull/4151/head
Slavi Pantaleev 1 year ago
parent
commit
1c68fd0d9b
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      roles/custom/matrix-synapse-reverse-proxy-companion/templates/nginx/conf.d/matrix-synapse-reverse-proxy-companion.conf.j2

+ 9
- 1
roles/custom/matrix-synapse-reverse-proxy-companion/templates/nginx/conf.d/matrix-synapse-reverse-proxy-companion.conf.j2 View File

@@ -16,10 +16,18 @@
{% macro render_worker_upstream(name, workers, load_balance) %}
{% if workers | length > 0 %}
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 }}
keepalive {{ ((workers | length) * 2) | string }};
resolver {{ matrix_synapse_reverse_proxy_companion_http_level_resolver }} valid=5s;
{% for worker in workers %}
server "{{ worker.name }}:{{ worker.port }}";
server "{{ worker.name }}:{{ worker.port }}" resolve;
{% endfor %}
}
{% endif %}


Loading…
Cancel
Save