繁体   English   中英

traefik docker标签中基于主机和路径的路由规则的混合

[英]Mixture of host and path based routing rules in traefik docker labels

我正在尝试使用docker标签创建一条前端规则,该规则将一对基于主机的路由以及一些基于路径的路由从一个域定向到一个后端,但是我很难找到正确的魔术来解决复杂的问题规则。

frontend.rule="Host:HostA.domain,HostB.domain,HostC.domain,Host:svc.domain;PathPrefix=/api/users, Host:svc.domain;PathPrefix=/api/other"

这似乎是orAnd逻辑的正确组合,但我似乎错了。

  • ,是OR运算符(仅在匹配器中有效,例如: Host:foo.com,bar.com
  • ; 是AND运算符(仅在匹配器之间起作用,例如: Host:foo.com;Path:/bar

Host:api.service;PathPrefixStrip:/foo

要使匹配器之间具有OR,您需要使用细分标签:

   # ...
   labels:
     - "traefik.enable=true"
     - "traefik.port=80"
     - "traefik.foo.frontend.rule=Host:api.mydomain.com"
     - "traefik.bar.frontend.rule=Host:www.mydomain.com,m.mydomain.com;PathPrefixStrp:/_"
   # ...

文档链接:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM