Make compress middleware for /.well-known/matrix/* configurable

This commit is contained in:
Slavi Pantaleev 2024-01-03 16:18:39 +02:00
parent e81a395a98
commit 97f40a95fb
2 changed files with 15 additions and 3 deletions

View File

@ -57,6 +57,11 @@ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_priority
matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_entrypoints: "{{ matrix_static_files_container_labels_traefik_entrypoints }}"
matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_tls: "{{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_entrypoints != 'web' }}"
matrix_static_files_container_labels_well_known_matrix_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_matrix_endpoint_middleware_compress_enabled: true
matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_minResponseBodyBytes: 100 # noqa var-naming
# Controls whether labels will be added that serve the base domain.
#
@ -77,7 +82,6 @@ matrix_static_files_container_labels_base_domain_traefik_entrypoints: "{{ matrix
matrix_static_files_container_labels_base_domain_traefik_tls: "{{ matrix_static_files_container_labels_base_domain_traefik_entrypoints != 'web' }}"
matrix_static_files_container_labels_base_domain_traefik_tls_certResolver: "{{ matrix_static_files_container_labels_traefik_tls_certResolver }}" # noqa var-naming
# matrix_static_files_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.
# See `../templates/labels.j2` for details.
#

View File

@ -13,11 +13,19 @@ traefik.http.services.{{ matrix_static_files_ident }}.loadbalancer.server.port={
#}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_enabled %}
{% set well_known_matrix_endpoint_middlewares = [] %}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_enabled %}
traefik.http.middlewares.{{ matrix_static_files_ident }}-well-known-endpoint-compress.compress=true
traefik.http.middlewares.{{ matrix_static_files_ident }}-well-known-endpoint-compress.compress.minResponseBodyBytes=100
traefik.http.middlewares.{{ matrix_static_files_ident }}-well-known-endpoint-compress.compress.minResponseBodyBytes={{ matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_minResponseBodyBytes }}
{% set well_known_matrix_endpoint_middlewares = well_known_matrix_endpoint_middlewares + [matrix_static_files_ident + '-well-known-endpoint-compress'] %}
{% endif %}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.rule={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_rule }}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.middlewares={{ matrix_static_files_ident }}-well-known-endpoint-compress
{% if well_known_matrix_endpoint_middlewares | length > 0 %}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.middlewares={{ well_known_matrix_endpoint_middlewares | join(',') }}
{% endif %}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_priority | int > 0 %}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.priority={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_priority }}