Add support for running synapse-admin (on Traefik) at the root path

Previously, we had to run it at a subpath, like `/synapse-admin`.

We can now dedicate a whole domain and the `/` path to it, should we
wish to do so.
housekeeping^2
Slavi Pantaleev 2 years ago
parent ff1338e003
commit 5ab5f28d14

@ -37,9 +37,9 @@ matrix_synapse_admin_container_extra_arguments: []
matrix_synapse_admin_container_labels_traefik_enabled: true
matrix_synapse_admin_container_labels_traefik_docker_network: "{{ matrix_synapse_admin_container_network }}"
matrix_synapse_admin_container_labels_traefik_hostname: "{{ matrix_server_fqn_matrix }}"
# The path prefix must not end with a slash
# The path prefix must either be `/` or not end with a slash (e.g. `/synapse-admin`).
matrix_synapse_admin_container_labels_traefik_path_prefix: /synapse-admin
matrix_synapse_admin_container_labels_traefik_rule: "Host(`{{ matrix_synapse_admin_container_labels_traefik_hostname }}`) && PathPrefix(`{{ matrix_synapse_admin_container_labels_traefik_path_prefix | quote }}`)"
matrix_synapse_admin_container_labels_traefik_rule: "Host(`{{ matrix_synapse_admin_container_labels_traefik_hostname }}`){% if matrix_synapse_admin_container_labels_traefik_path_prefix != '/' %} && PathPrefix(`{{ matrix_synapse_admin_container_labels_traefik_path_prefix | quote }}`){% endif %}"
matrix_synapse_admin_container_labels_traefik_entrypoints: web-secure
matrix_synapse_admin_container_labels_traefik_tls: "{{ matrix_synapse_admin_container_labels_traefik_entrypoints != 'web' }}"
matrix_synapse_admin_container_labels_traefik_tls_certResolver: default # noqa var-naming

@ -28,6 +28,5 @@
- name: Fail if matrix_synapse_admin_container_labels_traefik_path_prefix ends with a slash
ansible.builtin.fail:
msg: >-
matrix_synapse_admin_container_labels_traefik_path_prefix (`{{ matrix_synapse_admin_container_labels_traefik_path_prefix }}`) must not end with a slash.
Example: `/synapse-admin`.
when: "matrix_synapse_admin_container_labels_traefik_path_prefix[-1] == '/'"
matrix_synapse_admin_container_labels_traefik_path_prefix (`{{ matrix_synapse_admin_container_labels_traefik_path_prefix }}`) must either be `/` or not end with a slash (e.g. `/synapse-admin`).
when: "matrix_synapse_admin_container_labels_traefik_path_prefix != '/' and matrix_synapse_admin_container_labels_traefik_path_prefix[-1] == '/'"

@ -5,13 +5,23 @@ traefik.enable=true
traefik.docker.network={{ matrix_synapse_admin_container_labels_traefik_docker_network }}
{% endif %}
{% set middlewares = [] %}
{% if matrix_synapse_admin_container_labels_traefik_path_prefix != '/' %}
traefik.http.middlewares.matrix-synapse-admin-slashless-redirect.redirectregex.regex=({{ matrix_synapse_admin_container_labels_traefik_path_prefix | quote }})$
traefik.http.middlewares.matrix-synapse-admin-slashless-redirect.redirectregex.replacement=${1}/
{% set middlewares = middlewares + ['matrix-synapse-admin-slashless-redirect'] %}
{% endif %}
traefik.http.middlewares.matrix-synapse-admin-replacepath.replacepath.path=/
{% if matrix_synapse_admin_container_labels_traefik_path_prefix != '/' %}
traefik.http.middlewares.matrix-synapse-admin-strip-prefix.stripprefix.prefixes={{ matrix_synapse_admin_container_labels_traefik_path_prefix }}
{% set middlewares = middlewares + ['matrix-synapse-admin-strip-prefix'] %}
{% endif %}
traefik.http.routers.matrix-synapse-admin.rule={{ matrix_synapse_admin_container_labels_traefik_rule }}
traefik.http.routers.matrix-synapse-admin.middlewares=matrix-synapse-admin-slashless-redirect,matrix-synapse-admin-replacepath
{% if middlewares | length > 0 %}
traefik.http.routers.matrix-synapse-admin.middlewares={{ middlewares | join(',') }}
{% endif %}
traefik.http.routers.matrix-synapse-admin.service=matrix-synapse-admin
traefik.http.routers.matrix-synapse-admin.entrypoints={{ matrix_synapse_admin_container_labels_traefik_entrypoints }}
traefik.http.routers.matrix-synapse-admin.tls={{ matrix_synapse_admin_container_labels_traefik_tls | to_json }}

Loading…
Cancel
Save