Change Traefik media router rule generation to force priority

The web-secure-router could end up having priority over the web-media-router when the www subdomain was used.
This fix adds the www subdomain to the web-media-router if it's also present in the web-secure-router rule.
Traefik looks at the length of rules to determine priority when no explicit priority is set.
The web-media-router needs to always have priority over the web-secure-router in order for the media files to be served.
This commit is contained in:
Arkadiusz Ryś 2023-04-01 15:11:15 +02:00
parent 13fe0478d7
commit 213f623b93
No known key found for this signature in database
GPG Key ID: 8557F612E405EF84

View File

@ -60,7 +60,11 @@ http:
{%- if cookiecutter.cloud_provider == 'None' %}
web-media-router:
{%- if cookiecutter.domain_name.count('.') == 1 %}
rule: "(Host(`{{ cookiecutter.domain_name }}`) || Host(`www.{{ cookiecutter.domain_name }}`))&& PathPrefix(`/media/`)"
{%- else %}
rule: "Host(`{{ cookiecutter.domain_name }}`) && PathPrefix(`/media/`)"
{%- endif %}
entryPoints:
- web-secure
middlewares: