最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

traefik - Does naming matters when creating a routing rule? - Stack Overflow

programmeradmin3浏览0评论

The basic example for routing in the configuration is

version: "3"
services:
  my-container:
    # ...
    labels:
      - traefik.http.routers.my-container.rule=Host(`example`)

my-container is the name of the service and it is mentioned in the rule.

The example for multiple routes is different:

version: "3"
services:
  my-container:
    # ...
    labels:
      - traefik.http.routers.www-router.rule=Host(`example-a`)
      - traefik.http.routers.www-router.service=www-service
      - traefik.http.services.www-service.loadbalancer.server.port=8000
      - traefik.http.routers.admin-router.rule=Host(`example-b`)
      - traefik.http.routers.admin-router.service=admin-service
      - traefik.http.services.admin-service.loadbalancer.server.port=9000

Here the name of the service is not mentioned and made-up (?) names are used.

Does this mean that what is between routers and rule does not matter?

In other words could I always have (for all my containers) the same name, such as

(in one container)
traefik.http.routers.X.rule=Host(`example`)

(in another container)
traefik.http.routers.X.rule=Host(`foo`)

The basic example for routing in the configuration is

version: "3"
services:
  my-container:
    # ...
    labels:
      - traefik.http.routers.my-container.rule=Host(`example`)

my-container is the name of the service and it is mentioned in the rule.

The example for multiple routes is different:

version: "3"
services:
  my-container:
    # ...
    labels:
      - traefik.http.routers.www-router.rule=Host(`example-a`)
      - traefik.http.routers.www-router.service=www-service
      - traefik.http.services.www-service.loadbalancer.server.port=8000
      - traefik.http.routers.admin-router.rule=Host(`example-b`)
      - traefik.http.routers.admin-router.service=admin-service
      - traefik.http.services.admin-service.loadbalancer.server.port=9000

Here the name of the service is not mentioned and made-up (?) names are used.

Does this mean that what is between routers and rule does not matter?

In other words could I always have (for all my containers) the same name, such as

(in one container)
traefik.http.routers.X.rule=Host(`example`)

(in another container)
traefik.http.routers.X.rule=Host(`foo`)
Share Improve this question asked Feb 16 at 7:38 WoJWoJ 30k58 gold badges213 silver badges401 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You need to use different names for Traefik routers, middlewares and services - otherwise you are overwriting existing ones across Docker services.

发布评论

评论列表(0)

  1. 暂无评论