首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有多个子域的Traefik和具有子路径的URL

具有多个子域的Traefik和具有子路径的URL
EN

Stack Overflow用户
提问于 2019-05-20 06:40:58
回答 1查看 3.1K关注 0票数 2

安装程序: Docker (18.09.6),包含一个Traefik容器、Apache容器、多个其他容器(例如,运行在子路径后面的portainer )

Apache配置为

代码语言:javascript
复制
- traefik.frontend.rule=Host:${hostname},www.${hostname}

portainer配置为

代码语言:javascript
复制
- traefik.frontend.redirect.regex=^(.*)/portainer$$
- traefik.frontend.redirect.replacement=$$1/portainer/
- "traefik.frontend.rule=PathPrefix:/portainer;ReplacePathRegex: ^/portainer/(.*) /$$1"

Apache容器正在为URL、https://hostnamehttps://hostname/test提供服务。

通过https://hostname/portainer提供的维护者容器

安装成功了!

现在,我想扩展Apache容器的子域,如

代码语言:javascript
复制
- traefik.frontend.rule=Host:${hostname},autoconfig.${hostname},autodiscover.${hostname},mta-sts.${hostname},www.${hostname}

现在发生以下情况:

https://hostname工程

https://hostname/test工程

https://autodiscover.hostname工程

https://hostname/portainer 停止工作

根据日志,Traefik将流量路由到Apache容器,而不是维护者容器

这是可复制的,并与多个前端条目相关。我没有找到一个有超过2个前端规则的例子也尝试过

代码语言:javascript
复制
- traefik.frontend.rule=Host:${hostname},Host:www.${hostname},Host:autoconfig.${hostname}

代码语言:javascript
复制
- traefik.frontend.rule=Host:${hostname};Host:www.${hostname};Host:autoconfig.${hostname}

不管用..。

EN

回答 1

Stack Overflow用户

发布于 2019-05-24 15:17:34

答我自己的问题(请参考网址https://github.com/containous/traefik/issues/4904)

代码语言:javascript
复制
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添加到包含子路径的所有其他容器中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56215523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档