Don't host /.well-known/element/element.json file when Element Call is enabled

Various old guides mention this, but it seems like neither Element Web,
nor Element Desktop make use of it.

Element Web & Element Desktop use their own `config.json` configuration to figure out where
Element Call is.
This commit is contained in:
Slavi Pantaleev 2025-03-17 17:09:56 +02:00
parent e3b4128278
commit a32eec757b
7 changed files with 6 additions and 134 deletions

View File

@ -6118,7 +6118,6 @@ matrix_static_files_container_labels_traefik_entrypoints: "{{ traefik_entrypoint
matrix_static_files_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" matrix_static_files_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}"
matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_hostname: "{{ matrix_server_fqn_matrix }}" matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_hostname: "{{ matrix_server_fqn_matrix }}"
matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname: "{{ matrix_server_fqn_matrix }}"
# Base domain serving is not enabled by default (see `matrix_static_files_container_labels_base_domain_enabled`), # Base domain serving is not enabled by default (see `matrix_static_files_container_labels_base_domain_enabled`),
# but we pass the hostname, so that enabling it is easy. # but we pass the hostname, so that enabling it is easy.
@ -6153,8 +6152,6 @@ matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_auto
matrix_static_files_file_matrix_server_property_m_server: "{{ matrix_server_fqn_matrix_federation }}:{{ matrix_federation_public_port }}" matrix_static_files_file_matrix_server_property_m_server: "{{ matrix_server_fqn_matrix_federation }}:{{ matrix_federation_public_port }}"
matrix_static_files_file_element_element_json_property_call_widget_url: "{{ matrix_element_call_public_url if matrix_element_call_enabled else '' }}"
matrix_static_files_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}" matrix_static_files_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}"
matrix_static_files_self_check_hostname_matrix: "{{ matrix_server_fqn_matrix }}" matrix_static_files_self_check_hostname_matrix: "{{ matrix_server_fqn_matrix }}"

View File

@ -72,21 +72,6 @@ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_tls_cert
matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_enabled: true matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_enabled: true
matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_minResponseBodyBytes: 100 # noqa var-naming matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_minResponseBodyBytes: 100 # noqa var-naming
# Controls whether labels will be added that expose the `/.well-known/element` endpoint on the Matrix domain.
matrix_static_files_container_labels_well_known_element_endpoint_enabled: true
matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname: ''
matrix_static_files_container_labels_well_known_element_endpoint_traefik_path_prefix: /.well-known/element
matrix_static_files_container_labels_well_known_element_endpoint_traefik_rule: "Host(`{{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname }}`) && PathPrefix(`{{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_path_prefix }}`)"
matrix_static_files_container_labels_well_known_element_endpoint_traefik_priority: 0
matrix_static_files_container_labels_well_known_element_endpoint_traefik_entrypoints: "{{ matrix_static_files_container_labels_traefik_entrypoints }}"
matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls: "{{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_entrypoints != 'web' }}"
matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls_certResolver: "{{ matrix_static_files_container_labels_traefik_tls_certResolver }}" # noqa var-naming
# Controls whether the compress middleware (https://doc.traefik.io/traefik/middlewares/http/compress/) will be enabled for this router.
# The web-server only compresses known file types and our /.well-known/matrix/* files have no file extension.
# As such, they are not being compressed there and we compress them at the Traefik level.
matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_enabled: true
matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_minResponseBodyBytes: 100 # noqa var-naming
# Controls whether labels will be added that serve the base domain. # Controls whether labels will be added that serve the base domain.
# #
# This is similar to `matrix_static_files_container_labels_well_known_matrix_endpoint_*`, but does more. # This is similar to `matrix_static_files_container_labels_well_known_matrix_endpoint_*`, but does more.
@ -384,56 +369,6 @@ matrix_static_files_file_matrix_support_configuration: "{{ matrix_static_files_f
######################################################################## ########################################################################
########################################################################
# #
# Related to /.well-known/element/element.json #
# #
########################################################################
# Controls whether a `/.well-known/element/element.json` file is generated and used at all.
matrix_static_files_file_element_element_json_enabled: true
# Controls the call.widget_url property in the /.well-known/element/element.json file
matrix_static_files_file_element_element_json_property_call_widget_url: ''
# Default /.well-known/element/element.json configuration template which covers the generic use case.
# You can customize it by controlling the various variables inside it.
#
# For a more advanced customization, you can extend the default (see `matrix_static_files_file_matrix_support_configuration_extension_json`)
# or completely replace this variable with your own template.
matrix_static_files_file_element_element_json_configuration_json: "{{ lookup('template', 'templates/public/.well-known/element/element.json.j2') }}"
# Your custom JSON configuration for /.well-known/element/element.json should go to `matrix_static_files_file_element_element_json_configuration_extension_json`.
# This configuration extends the default starting configuration (`matrix_static_files_file_matrix_support_configuration_extension_json`).
#
# You can override individual variables from the default configuration, or introduce new ones.
#
# If you need something more special, you can take full control by
# completely redefining `matrix_static_files_file_matrix_support_configuration_json`.
#
# Example configuration extension follows:
#
# matrix_static_files_file_element_element_json_configuration_extension_json: |
# {
# "call": {
# "url": "value"
# }
# }
matrix_static_files_file_element_element_json_configuration_extension_json: '{}'
matrix_static_files_file_element_element_json_configuration_extension: "{{ matrix_static_files_file_element_element_json_configuration_extension_json | from_json if matrix_static_files_file_element_element_json_configuration_extension_json | from_json is mapping else {} }}"
# Holds the final /.well-known/matrix/support configuration (a combination of the default and its extension).
# You most likely don't need to touch this variable. Instead, see `matrix_static_files_file_element_element_json_configuration_json` or `matrix_static_files_file_element_element_json_configuration_extension_json`.
matrix_static_files_file_element_element_json_configuration: "{{ matrix_static_files_file_element_element_json_configuration_json | combine(matrix_static_files_file_element_element_json_configuration_extension, recursive=True) }}"
########################################################################
# #
# /Related to /.well-known/element/element.json #
# #
########################################################################
######################################################################## ########################################################################
# # # #
# Related to index.html # # Related to index.html #

View File

@ -18,9 +18,14 @@
- {path: "{{ matrix_static_files_public_path }}", when: true} - {path: "{{ matrix_static_files_public_path }}", when: true}
- {path: "{{ matrix_static_files_public_well_known_path }}", when: true} - {path: "{{ matrix_static_files_public_well_known_path }}", when: true}
- {path: "{{ matrix_static_files_public_well_known_matrix_path }}", when: true} - {path: "{{ matrix_static_files_public_well_known_matrix_path }}", when: true}
- {path: "{{ matrix_static_files_public_well_known_element_path }}", when: true}
when: "item.when | bool" when: "item.when | bool"
# This is not necessary anymore, so we're cleaning it up.
- name: Ensure matrix-static-files element path doesn't exist
ansible.builtin.file:
path: "{{ matrix_static_files_public_well_known_element_path }}"
state: absent
- name: Ensure matrix-static-files is configured - name: Ensure matrix-static-files is configured
ansible.builtin.template: ansible.builtin.template:
src: "{{ item.src }}" src: "{{ item.src }}"
@ -59,10 +64,6 @@
dest: "{{ matrix_static_files_public_well_known_matrix_path }}/support" dest: "{{ matrix_static_files_public_well_known_matrix_path }}/support"
when: "{{ matrix_static_files_file_matrix_support_enabled }}" when: "{{ matrix_static_files_file_matrix_support_enabled }}"
- content: "{{ matrix_static_files_file_element_element_json_configuration | to_nice_json }}"
dest: "{{ matrix_static_files_public_well_known_element_path }}/element.json"
when: "{{ matrix_static_files_file_element_element_json_enabled }}"
# This one will not be deleted if `matrix_static_files_file_index_html_enabled` flips to `false`. # This one will not be deleted if `matrix_static_files_file_index_html_enabled` flips to `false`.
# See the comment for `matrix_static_files_file_index_html_enabled` to learn why. # See the comment for `matrix_static_files_file_index_html_enabled` to learn why.
- content: "{{ matrix_static_files_file_index_html_template }}" - content: "{{ matrix_static_files_file_index_html_template }}"
@ -81,12 +82,6 @@
state: absent state: absent
when: "not matrix_static_files_file_matrix_support_enabled | bool" when: "not matrix_static_files_file_matrix_support_enabled | bool"
- name: Ensure /.well-known/element/element.json file deleted if not enabled
ansible.builtin.file:
path: "{{ matrix_static_files_public_well_known_element_path }}/element.json"
state: absent
when: "not matrix_static_files_file_element_element_json_enabled | bool"
- name: Ensure matrix-static-files container image is pulled - name: Ensure matrix-static-files container image is pulled
community.docker.docker_image: community.docker.docker_image:
name: "{{ matrix_static_files_container_image }}" name: "{{ matrix_static_files_container_image }}"

View File

@ -13,9 +13,6 @@
- {'name': 'matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_hostname', when: "{{ matrix_static_files_container_labels_well_known_matrix_endpoint_enabled }}"} - {'name': 'matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_hostname', when: "{{ matrix_static_files_container_labels_well_known_matrix_endpoint_enabled }}"}
- {'name': 'matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_well_known_matrix_endpoint_enabled }}"} - {'name': 'matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_well_known_matrix_endpoint_enabled }}"}
- {'name': 'matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname', when: "{{ matrix_static_files_container_labels_well_known_element_endpoint_enabled }}"}
- {'name': 'matrix_static_files_container_labels_well_known_element_endpoint_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_well_known_element_endpoint_enabled }}"}
- {'name': 'matrix_static_files_container_labels_base_domain_traefik_hostname', when: "{{ matrix_static_files_container_labels_base_domain_enabled }}"} - {'name': 'matrix_static_files_container_labels_base_domain_traefik_hostname', when: "{{ matrix_static_files_container_labels_base_domain_enabled }}"}
- {'name': 'matrix_static_files_container_labels_base_domain_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_base_domain_enabled }}"} - {'name': 'matrix_static_files_container_labels_base_domain_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_base_domain_enabled }}"}

View File

@ -56,47 +56,6 @@ traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-matrix.tls.
{% endif %} {% endif %}
{% if matrix_static_files_container_labels_well_known_element_endpoint_enabled %}
############################################################
# #
# Related to /.well-known/element on the Matrix domain #
# #
############################################################
{% set well_known_element_endpoint_middlewares = [] %}
{% if matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_enabled %}
traefik.http.middlewares.{{ matrix_static_files_identifier }}-well-known-element-compress.compress=true
traefik.http.middlewares.{{ matrix_static_files_identifier }}-well-known-element-compress.compress.minResponseBodyBytes={{ matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_minResponseBodyBytes }}
{% set well_known_element_endpoint_middlewares = well_known_element_endpoint_middlewares + [matrix_static_files_identifier + '-well-known-element-compress'] %}
{% endif %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.rule={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_rule }}
{% if well_known_element_endpoint_middlewares | length > 0 %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.middlewares={{ well_known_element_endpoint_middlewares | join(',') }}
{% endif %}
{% if matrix_static_files_container_labels_well_known_element_endpoint_traefik_priority | int > 0 %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.priority={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_priority }}
{% endif %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.service={{ matrix_static_files_identifier }}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.entrypoints={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_entrypoints }}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.tls={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls | to_json }}
{% if matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.tls.certResolver={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls_certResolver }}
{% endif %}
############################################################
# #
# /Related to /.well-known/element on the Matrix domain #
# #
############################################################
{% endif %}
{% if matrix_static_files_container_labels_base_domain_enabled %} {% if matrix_static_files_container_labels_base_domain_enabled %}
############################################################ ############################################################
# # # #

View File

@ -1,7 +0,0 @@
{
{% if matrix_static_files_file_element_element_json_property_call_widget_url %}
"call": {
"widget_url": {{ matrix_static_files_file_element_element_json_property_call_widget_url | to_json }}
}
{% endif %}
}

View File

@ -1,4 +0,0 @@
SPDX-FileCopyrightText: 2024 wjbeckett
SPDX-FileCopyrightText: 2024 Slavi Pantaleev
SPDX-License-Identifier: AGPL-3.0-or-later