diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index d5ff7483d..cfd383652 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -4467,6 +4467,9 @@ matrix_client_element_container_labels_traefik_docker_network: "{{ matrix_playbo matrix_client_element_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" matrix_client_element_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" +matrix_client_element_container_labels_traefik_compression_middleware_enabled: "{{ matrix_playbook_reverse_proxy_traefik_middleware_compession_enabled }}" +matrix_client_element_container_labels_traefik_compression_middleware_name: "{{ matrix_playbook_reverse_proxy_traefik_middleware_compession_name if matrix_playbook_reverse_proxy_traefik_middleware_compession_enabled else '' }}" + matrix_client_element_default_hs_url: "{{ matrix_homeserver_url }}" matrix_client_element_default_is_url: "{{ matrix_identity_server_url }}" @@ -4516,6 +4519,9 @@ matrix_client_hydrogen_container_labels_traefik_docker_network: "{{ matrix_playb matrix_client_hydrogen_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" matrix_client_hydrogen_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" +matrix_client_hydrogen_container_labels_traefik_compression_middleware_enabled: "{{ matrix_playbook_reverse_proxy_traefik_middleware_compession_enabled }}" +matrix_client_hydrogen_container_labels_traefik_compression_middleware_name: "{{ matrix_playbook_reverse_proxy_traefik_middleware_compession_name if matrix_playbook_reverse_proxy_traefik_middleware_compession_enabled else '' }}" + matrix_client_hydrogen_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}" matrix_client_hydrogen_default_hs_url: "{{ matrix_homeserver_url }}" @@ -4549,6 +4555,9 @@ matrix_client_cinny_container_labels_traefik_docker_network: "{{ matrix_playbook matrix_client_cinny_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" matrix_client_cinny_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" +matrix_client_cinny_container_labels_traefik_compression_middleware_enabled: "{{ matrix_playbook_reverse_proxy_traefik_middleware_compession_enabled }}" +matrix_client_cinny_container_labels_traefik_compression_middleware_name: "{{ matrix_playbook_reverse_proxy_traefik_middleware_compession_name if matrix_playbook_reverse_proxy_traefik_middleware_compession_enabled else '' }}" + matrix_client_cinny_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}" matrix_client_cinny_default_hs_url: "{{ matrix_homeserver_url }}" diff --git a/roles/custom/matrix-client-cinny/defaults/main.yml b/roles/custom/matrix-client-cinny/defaults/main.yml index ef32d37a5..2137fed70 100644 --- a/roles/custom/matrix-client-cinny/defaults/main.yml +++ b/roles/custom/matrix-client-cinny/defaults/main.yml @@ -44,6 +44,11 @@ matrix_client_cinny_container_labels_traefik_entrypoints: web-secure matrix_client_cinny_container_labels_traefik_tls: "{{ matrix_client_cinny_container_labels_traefik_entrypoints != 'web' }}" matrix_client_cinny_container_labels_traefik_tls_certResolver: default # noqa var-naming +# Controls whether a compression middleware will be injected into the middlewares list. +# This compression middleware is supposed to be defined elsewhere (using labels or a File provider, etc.) and is merely referenced by this router. +matrix_client_cinny_container_labels_traefik_compression_middleware_enabled: false +matrix_client_cinny_container_labels_traefik_compression_middleware_name: "" + # Controls which additional headers to attach to all HTTP responses. # To add your own headers, use `matrix_client_cinny_container_labels_traefik_additional_response_headers_custom` matrix_client_cinny_container_labels_traefik_additional_response_headers: "{{ matrix_client_cinny_container_labels_traefik_additional_response_headers_auto | combine(matrix_client_cinny_container_labels_traefik_additional_response_headers_custom) }}" diff --git a/roles/custom/matrix-client-cinny/tasks/validate_config.yml b/roles/custom/matrix-client-cinny/tasks/validate_config.yml index a7d4f70f2..7a7ee2dfe 100644 --- a/roles/custom/matrix-client-cinny/tasks/validate_config.yml +++ b/roles/custom/matrix-client-cinny/tasks/validate_config.yml @@ -3,10 +3,11 @@ ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) to use Cinny. - when: "vars[item] == '' or vars[item] is none" + when: "item.when | bool and vars[item.name] == ''" with_items: - - matrix_client_cinny_default_hs_url - - matrix_client_cinny_container_network + - {'name': 'matrix_client_cinny_default_hs_url', when: true} + - {'name': 'matrix_client_cinny_container_network', when: true} + - {'name': 'matrix_client_cinny_container_labels_traefik_compression_middleware_name', when: "{{ matrix_client_cinny_container_labels_traefik_compression_middleware_enabled }}"} - name: Fail if matrix_client_cinny_path_prefix is not / ansible.builtin.fail: diff --git a/roles/custom/matrix-client-cinny/templates/labels.j2 b/roles/custom/matrix-client-cinny/templates/labels.j2 index ede967226..e18e804c0 100644 --- a/roles/custom/matrix-client-cinny/templates/labels.j2 +++ b/roles/custom/matrix-client-cinny/templates/labels.j2 @@ -9,6 +9,10 @@ traefik.http.services.matrix-client-cinny.loadbalancer.server.port=8080 {% set middlewares = [] %} +{% if matrix_client_cinny_container_labels_traefik_compression_middleware_enabled %} +{% set middlewares = middlewares + [matrix_client_cinny_container_labels_traefik_compression_middleware_name] %} +{% endif %} + {% if matrix_client_cinny_container_labels_traefik_path_prefix != '/' %} traefik.http.middlewares.matrix-client-cinny-slashless-redirect.redirectregex.regex=({{ matrix_client_cinny_container_labels_traefik_path_prefix | quote }})$ traefik.http.middlewares.matrix-client-cinny-slashless-redirect.redirectregex.replacement=${1}/ diff --git a/roles/custom/matrix-client-element/defaults/main.yml b/roles/custom/matrix-client-element/defaults/main.yml index d8eed40ae..d8b33102f 100644 --- a/roles/custom/matrix-client-element/defaults/main.yml +++ b/roles/custom/matrix-client-element/defaults/main.yml @@ -48,6 +48,11 @@ matrix_client_element_container_labels_traefik_entrypoints: web-secure matrix_client_element_container_labels_traefik_tls: "{{ matrix_client_element_container_labels_traefik_entrypoints != 'web' }}" matrix_client_element_container_labels_traefik_tls_certResolver: default # noqa var-naming +# Controls whether a compression middleware will be injected into the middlewares list. +# This compression middleware is supposed to be defined elsewhere (using labels or a File provider, etc.) and is merely referenced by this router. +matrix_client_element_container_labels_traefik_compression_middleware_enabled: false +matrix_client_element_container_labels_traefik_compression_middleware_name: "" + # Controls which additional headers to attach to all HTTP responses. # To add your own headers, use `matrix_client_element_container_labels_traefik_additional_response_headers_custom` matrix_client_element_container_labels_traefik_additional_response_headers: "{{ matrix_client_element_container_labels_traefik_additional_response_headers_auto | combine(matrix_client_element_container_labels_traefik_additional_response_headers_custom) }}" diff --git a/roles/custom/matrix-client-element/tasks/validate_config.yml b/roles/custom/matrix-client-element/tasks/validate_config.yml index 81e00ddac..a61d8bcaf 100644 --- a/roles/custom/matrix-client-element/tasks/validate_config.yml +++ b/roles/custom/matrix-client-element/tasks/validate_config.yml @@ -4,10 +4,11 @@ ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) for using Element Web. - when: "vars[item] == ''" + when: "item.when | bool and vars[item.name] == ''" with_items: - - matrix_client_element_default_hs_url - - matrix_client_element_container_network + - {'name': 'matrix_client_element_default_hs_url', when: true} + - {'name': 'matrix_client_element_container_network', when: true} + - {'name': 'matrix_client_element_container_labels_traefik_compression_middleware_name', when: "{{ matrix_client_element_container_labels_traefik_compression_middleware_enabled }}"} - name: Fail if Element location sharing enabled, but no tile server defined ansible.builtin.fail: diff --git a/roles/custom/matrix-client-element/templates/labels.j2 b/roles/custom/matrix-client-element/templates/labels.j2 index 8de199918..67ed2b95a 100644 --- a/roles/custom/matrix-client-element/templates/labels.j2 +++ b/roles/custom/matrix-client-element/templates/labels.j2 @@ -9,6 +9,10 @@ traefik.http.services.matrix-client-element.loadbalancer.server.port=8080 {% set middlewares = [] %} +{% if matrix_client_element_container_labels_traefik_compression_middleware_enabled %} +{% set middlewares = middlewares + [matrix_client_element_container_labels_traefik_compression_middleware_name] %} +{% endif %} + {% if matrix_client_element_container_labels_traefik_path_prefix != '/' %} traefik.http.middlewares.matrix-client-element-slashless-redirect.redirectregex.regex=({{ matrix_client_element_container_labels_traefik_path_prefix | quote }})$ traefik.http.middlewares.matrix-client-element-slashless-redirect.redirectregex.replacement=${1}/ diff --git a/roles/custom/matrix-client-hydrogen/defaults/main.yml b/roles/custom/matrix-client-hydrogen/defaults/main.yml index 480492b42..78d1b8618 100644 --- a/roles/custom/matrix-client-hydrogen/defaults/main.yml +++ b/roles/custom/matrix-client-hydrogen/defaults/main.yml @@ -43,6 +43,11 @@ matrix_client_hydrogen_container_labels_traefik_entrypoints: web-secure matrix_client_hydrogen_container_labels_traefik_tls: "{{ matrix_client_hydrogen_container_labels_traefik_entrypoints != 'web' }}" matrix_client_hydrogen_container_labels_traefik_tls_certResolver: default # noqa var-naming +# Controls whether a compression middleware will be injected into the middlewares list. +# This compression middleware is supposed to be defined elsewhere (using labels or a File provider, etc.) and is merely referenced by this router. +matrix_client_hydrogen_container_labels_traefik_compression_middleware_enabled: false +matrix_client_hydrogen_container_labels_traefik_compression_middleware_name: "" + # Controls which additional headers to attach to all HTTP responses. # To add your own headers, use `matrix_client_hydrogen_container_labels_traefik_additional_response_headers_custom` matrix_client_hydrogen_container_labels_traefik_additional_response_headers: "{{ matrix_client_hydrogen_container_labels_traefik_additional_response_headers_auto | combine(matrix_client_hydrogen_container_labels_traefik_additional_response_headers_custom) }}" diff --git a/roles/custom/matrix-client-hydrogen/tasks/validate_config.yml b/roles/custom/matrix-client-hydrogen/tasks/validate_config.yml index 73452f831..93b9354eb 100644 --- a/roles/custom/matrix-client-hydrogen/tasks/validate_config.yml +++ b/roles/custom/matrix-client-hydrogen/tasks/validate_config.yml @@ -4,10 +4,11 @@ ansible.builtin.fail: msg: > You need to define a required configuration setting (`{{ item }}`) to use Hydrogen. - when: "(vars[item] == '' or vars[item] is none) and matrix_client_hydrogen_container_image_self_build | bool" + when: "item.when | bool and vars[item.name] == ''" with_items: - - matrix_client_hydrogen_default_hs_url - - matrix_client_hydrogen_container_network + - {'name': 'matrix_client_hydrogen_default_hs_url', when: "{{ matrix_client_hydrogen_container_image_self_build }}"} + - {'name': 'matrix_client_hydrogen_container_network', when: true} + - {'name': 'matrix_client_hydrogen_container_labels_traefik_compression_middleware_name', when: "{{ matrix_client_hydrogen_container_labels_traefik_compression_middleware_enabled }}"} - when: matrix_client_hydrogen_container_labels_traefik_enabled | bool block: diff --git a/roles/custom/matrix-client-hydrogen/templates/labels.j2 b/roles/custom/matrix-client-hydrogen/templates/labels.j2 index f5ccf8c97..011d02d1d 100644 --- a/roles/custom/matrix-client-hydrogen/templates/labels.j2 +++ b/roles/custom/matrix-client-hydrogen/templates/labels.j2 @@ -9,6 +9,10 @@ traefik.http.services.matrix-client-hydrogen.loadbalancer.server.port=8080 {% set middlewares = [] %} +{% if matrix_client_hydrogen_container_labels_traefik_compression_middleware_enabled %} +{% set middlewares = middlewares + [matrix_client_hydrogen_container_labels_traefik_compression_middleware_name] %} +{% endif %} + {% if matrix_client_hydrogen_container_labels_traefik_path_prefix != '/' %} traefik.http.middlewares.matrix-client-hydrogen-slashless-redirect.redirectregex.regex=({{ matrix_client_hydrogen_container_labels_traefik_path_prefix | quote }})$ traefik.http.middlewares.matrix-client-hydrogen-slashless-redirect.redirectregex.replacement=${1}/