安装程序: Docker (18.09.6),包含一个Traefik容器、Apache容器、多个其他容器(例如,运行在子路径后面的portainer )
Apache配置为
- traefik.frontend.rule=Host:${hostname},www.${hostname}portainer配置为
- traefik.frontend.redirect.regex=^(.*)/portainer$$
- traefik.frontend.redirect.replacement=$$1/portainer/
- "traefik.frontend.rule=PathPrefix:/portainer;ReplacePathRegex: ^/portainer/(.*) /$$1"Apache容器正在为URL、https://hostname和https://hostname/test提供服务。
通过https://hostname/portainer提供的维护者容器
安装成功了!
现在,我想扩展Apache容器的子域,如
- traefik.frontend.rule=Host:${hostname},autoconfig.${hostname},autodiscover.${hostname},mta-sts.${hostname},www.${hostname}现在发生以下情况:
https://autodiscover.hostname工程
https://hostname/portainer 停止工作
根据日志,Traefik将流量路由到Apache容器,而不是维护者容器
这是可复制的,并与多个前端条目相关。我没有找到一个有超过2个前端规则的例子也尝试过
- traefik.frontend.rule=Host:${hostname},Host:www.${hostname},Host:autoconfig.${hostname}或
- traefik.frontend.rule=Host:${hostname};Host:www.${hostname};Host:autoconfig.${hostname}不管用..。
发布于 2019-05-24 15:17:34
答我自己的问题(请参考网址https://github.com/containous/traefik/issues/4904)
The issue you are encountering is that you have overlapping rules, and you are not defining any priority to determine order of rule execution.
From the documentation (https://docs.traefik.io/basics/#priorities):
By default, routes will be sorted (in descending order) using rules length
So since you have made the host rule much longer, and it matches, it is the first rule.
You can use the priority label to manually force the match of the portainer path first, before the base host match.将traefik.frontend.priority=1添加到我的Apache容器中,将traefik.frontend.priority=2添加到包含子路径的所有其他容器中。
https://stackoverflow.com/questions/56215523
复制相似问题