Search code examples
dockerdocker-composenexustraefik

traefik two port and 2 hosts


I'm trying to run Nexus in swarm with traefik, nexus has a admin interface that runs on port 8081 and also has a nexus docker registry repository running on port 9615.

My goal is access registry through registry.docker.domain and nexus by nexus.domain but I am not able to do this.

traefik config on compose

ports:
  - 8081
  - 9615
deploy:
  labels:
    - "traefik.enable=true"
    # Config Nexus
    - "traefik.http.router.nexus.rule=Host('nexus.domain')"
    - "traefik.http.services.nexus.loadbalancer.server.port=8081"
    - "traefik.http.routers.nexus.entrypoints=web-secure"
    - "traefik.http.routers.nexus.service=nexus"

    # Config Registry
    - "traefik.http.router.registry.rule=Host('registry.docker')"
    - "traefik.http.services.registry.loadbalancer.server.port=9615"
    - "traefik.http.routers.registry.entrypoints=web-secure"
    - "traefik.http.routers.registry.tls=true"
    - "traefik.http.routers.registry.service=registry"

If I set up only registry labels I can access the registry by https.://registry.domanin and nexus by registry.domain:PORT

If I set up only nexus labels I can access nexus by http:.//Nexus.domain

But the config above, with labels for both at the same time, didn't work, nexus and registry return 404.

Obs: I'm using traefik 2.2, the documentation and the use are very different from 1.6


Solution

  • Isn't there just a typo in traefik.http.router.* -- shouldn't it be like traefik.http.routers.*? It could explain why domain names are not recognized and only ports are used with separate labels definitions.

    Also one other typo in Host rule -- there should be back quote char used, not apostrophe. I.e. instead of

    "traefik.http.router.nexus.rule=Host('nexus.domain')"
    

    it should be

    "traefik.http.routers.nexus.rule=Host(`nexus.domain`)"
    

    Similar for the registry entry.