【问题标题】:Redirecting a path to the same container but different port with Traefik使用 Traefik 将路径重定向到同一个容器但不同的端口
【发布时间】:2017-06-08 08:34:51
【问题描述】:

我使用 docker compose 进行了以下设置(运行 swarm 模式):

mydomain.com --> ContainerA:8080

但我想要的是通过标签,为同一个容器指定以下内容:

mydomain.com/test --> ContainerA:80
mydomain.com --> ContainerA:8080

到目前为止,我在撰写中有以下标签:

deploy:
  labels:
    - traefik.port=8080
    - traefik.docker.network=apps
    - traefik.protocol=http
    - traefik.frontend.rule=Host:mydomain.com

提前致谢

编辑:

现在我按照您的建议尝试了这个。这是我设置的,但仍然无法正常工作,我收到 404 错误:

- traefik.docker.network=apps - traefik.main.protocol=http - traefik.main.port=8069 - traefik.main.frontend.rule=Host:odoo.mydomain.com - traefik.worker.port=8072 - traefik.worker.protocol=http - traefik.worker.frontend.rule=Host:odoo.mydomain.com;PathPrefixStrip:/longpolling

【问题讨论】:

  • 你最终解决了这个问题吗?在我看来,您需要将 odoo.mydomain.com 和 worker.mydomain.com 等不同的主机名定向到容器中的不同内部端口。

标签: traefik


【解决方案1】:

如果你需要绑定一个容器的多个端口,你必须使用documentation中描述的traefik.<service-name>.*标签。 例如,

deploy:
  labels:
    - traefik.first.port=80
    - traefik.first.frontend.rule=Host:mydomain.com;PathPrefixStrip:/test
    - traefik.second.port=8080
    - traefik.second.frontend.rule=Host:mydomain.com

【讨论】:

  • 谢谢。但是,您所说的 是什么意思?我必须输入服务的名称吗?我的意思是,我在创建 docker 服务时给容器起的名字?
  • 这可能是相关的,这就是为什么它对我不起作用?github.com/containous/traefik/issues/1321
  • 您的选择!您必须为您的服务命名。
猜你喜欢
  • 2019-09-25
  • 2017-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-20
  • 1970-01-01
  • 2021-03-18
  • 2015-10-09
相关资源
最近更新 更多