From 1313f1e4149218b4d20ff01e795daedfd32c7a39 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 11 Mar 2025 19:05:18 +0200 Subject: [PATCH] Make base domain root path redirect also handle URLs with query strings (passing them along) Previously `https://example.com` and `https://example.com/` would be redirected to `https://matrix.example.com`. However, `https://example.com/?something` was not handled and was tried to be served as a file by matrix-static-files for this base domain. From now on, paths containing query strings will be handled as well and the query string will be passed along. Example: `https://example.com/?something` -> `https://matrix.example.com/?something` --- group_vars/matrix_servers | 2 +- roles/custom/matrix-static-files/defaults/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index cc7a09de6..f3eca1dc7 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -6094,7 +6094,7 @@ matrix_static_files_container_labels_base_domain_traefik_hostname: "{{ matrix_do # If we're not serving a static webpage, serve a redirect instead of a 404. matrix_static_files_container_labels_base_domain_root_path_redirection_enabled: "{{ not matrix_static_files_file_index_html_enabled }}" -matrix_static_files_container_labels_base_domain_root_path_redirection_url: "{{ ('https://' if matrix_playbook_ssl_enabled else 'http://') + matrix_server_fqn_matrix }}" +matrix_static_files_container_labels_base_domain_root_path_redirection_url: "{{ ('https://' if matrix_playbook_ssl_enabled else 'http://') + matrix_server_fqn_matrix }}/${1}" matrix_static_files_file_matrix_client_property_io_element_jitsi_preferred_domain: "{{ matrix_server_fqn_jitsi if jitsi_enabled else '' }}" diff --git a/roles/custom/matrix-static-files/defaults/main.yml b/roles/custom/matrix-static-files/defaults/main.yml index 045d28b70..38d014157 100644 --- a/roles/custom/matrix-static-files/defaults/main.yml +++ b/roles/custom/matrix-static-files/defaults/main.yml @@ -91,7 +91,7 @@ matrix_static_files_container_labels_base_domain_traefik_tls: "{{ matrix_static_ matrix_static_files_container_labels_base_domain_traefik_tls_certResolver: "{{ matrix_static_files_container_labels_traefik_tls_certResolver }}" # noqa var-naming # Controls whether the root path (/) at the base domain would respond with a redirect to some URL. matrix_static_files_container_labels_base_domain_root_path_redirection_enabled: false -matrix_static_files_container_labels_base_domain_root_path_redirection_regex: "^{{ matrix_static_files_scheme }}://{{ matrix_static_files_container_labels_base_domain_traefik_hostname }}{{ matrix_static_files_container_labels_base_domain_traefik_path_prefix }}$" +matrix_static_files_container_labels_base_domain_root_path_redirection_regex: "^{{ matrix_static_files_scheme }}://{{ matrix_static_files_container_labels_base_domain_traefik_hostname }}{{ matrix_static_files_container_labels_base_domain_traefik_path_prefix }}(\\?.*)?$" matrix_static_files_container_labels_base_domain_root_path_redirection_url: "" # matrix_static_files_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.