Skip to content

Commit

Permalink
Add HTTP-compression support
Browse files Browse the repository at this point in the history
  • Loading branch information
spantaleev committed Nov 15, 2024
1 parent 03f211f commit 2138b68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ gitea_container_labels_traefik_entrypoints: web-secure
gitea_container_labels_traefik_tls: "{{ gitea_container_labels_traefik_entrypoints != 'web' }}"
gitea_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.
gitea_container_labels_traefik_compression_middleware_enabled: false
gitea_container_labels_traefik_compression_middleware_name: ""

# Controls which additional headers to attach to all HTTP requests.
# To add your own custom request headers, use `gitea_container_labels_traefik_additional_response_headers_custom`
gitea_container_labels_traefik_additional_request_headers: "{{ gitea_container_labels_traefik_additional_request_headers_auto | combine(gitea_container_labels_traefik_additional_request_headers_custom) }}"
Expand Down
17 changes: 9 additions & 8 deletions tasks/validate_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
- name: Fail if required Gitea settings not defined
ansible.builtin.fail:
msg: >-
You need to define a required configuration setting (`{{ item }}`) for using this role.
when: "vars[item] == ''"
You need to define a required configuration setting (`{{ item.name }}`) for using this role.
when: "item.when | bool and vars[item.name] | length == 0"
with_items:
- gitea_hostname
- gitea_uid
- gitea_gid
- gitea_config_database_hostname
- gitea_config_database_username
- gitea_config_database_password
- {'name': 'gitea_hostname', when: true}
- {'name': 'gitea_uid', when: true}
- {'name': 'gitea_gid', when: true}
- {'name': 'gitea_config_database_hostname', when: true}
- {'name': 'gitea_config_database_username', when: true}
- {'name': 'gitea_config_database_password', when: true}
- {'name': 'gitea_container_labels_traefik_compression_middleware_name', when: "{{ gitea_container_labels_traefik_compression_middleware_enabled }}"}

- when: gitea_container_labels_traefik_enabled | bool
block:
Expand Down
4 changes: 4 additions & 0 deletions templates/labels.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ traefik.docker.network={{ gitea_container_labels_traefik_docker_network }}

{% set middlewares = [] %}

{% if gitea_container_labels_traefik_compression_middleware_enabled %}
{% set middlewares = middlewares + [gitea_container_labels_traefik_compression_middleware_name] %}
{% endif %}

{% if gitea_container_labels_traefik_path_prefix != '/' %}
traefik.http.middlewares.{{ gitea_identifier }}-slashless-redirect.redirectregex.regex=^({{ gitea_container_labels_traefik_path_prefix | quote }})$
traefik.http.middlewares.{{ gitea_identifier }}-slashless-redirect.redirectregex.replacement=${1}/
Expand Down

0 comments on commit 2138b68

Please sign in to comment.