How can I solve namespace conflicts with the dashboard api?

Hey Traefik Community,

first of all I really like Traefik and I use it for quite a while. Yesterday I upgraded to version two and I really appreciate the effort the whole Traefik Team put in the software.

Here my problem: I have a service named 'api' which i cannot rename. I use docker-compose in my setup and would like to make use of the dashboard api. On default my routes are called like the services in docker-compose. How would I go about handling the naming collision?

  api:
    image: api:latest
    container_name: api
    labels:
      - traefik.http.routers.api.rule=Host(`api.example.org`)

In this example the routers.api refers to the dashboard api.

And one more question. How can I set the dashboard on one of my subdomains, like dashboard.website.com.

Best regards,

Thilo

Hello,

traefik.http.routers.<name>.rule

the <name> must be unique.

You can use something like that:

  traefik:
    image: traefik:v2.0.0
    ports:
      - 80:80
    command:
      - --api
      - --entrypoints.web.address=:80
      - --providers.docker.exposedbydefault=false
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.rule=Host(`traefik.mydomain.com`)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.entrypoints=web"

https://docs.traefik.io/v2.0/operations/api/#configuration

1 Like

Also with the defaultRule you can generate "smart" Host rule

https://docs.traefik.io/v2.0/providers/docker/#defaultrule

So i can still use the api as a custom service? I got mixed up because the docs use api as service name :stuck_out_tongue:

Thank you for the fast reply!

1 Like