How to route two routers to the same docker container and port?

I want to expose some routers of a container to the internet, but allow then on a different route (and port) on the local network. Only $TRAEFIKPORT, used for websecure is exposed on the router firewall.

Is there any way to do it?

Error message:

2025-05-17T15:57:42Z ERR Router passwords-api cannot be linked automatically with multiple Services: ["passwords-api" "passwords"] providerName=docker routerName=passwords-api
2025-05-17T15:57:42Z ERR Router passwords cannot be linked automatically with multiple Services: ["passwords-api" "passwords"] providerName=docker routerName=passwords

passwords:
    image: vaultwarden/server:latest
    container_name: passwords
    networks:
      - lab
    restart: unless-stopped
    user: "${UID}:${GID}"
    env_file:
      - default.env
    environment:
      - DOMAIN=https://pass.${DOMAIN}:${TRAEFIKPORT}
      - SIGNUPS_ALLOWED=false
      # - ADMIN_TOKEN=${VAULTWARDEN_ADMIN_TOKEN}
      # - DISABLE_ADMIN_TOKEN=true
    # ports:
    #   - 80:80
    volumes:
      - $CONFIG/passwords/:/data/
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    labels:
      - "traefik.enable=true"

      - "traefik.http.routers.passwords.rule=Host(`pass.${DOMAIN}`)"
      - "traefik.http.routers.passwords.entrypoints=localonly"
      - "traefik.http.routers.passwords.tls.certresolver=myresolver"
      - "traefik.http.services.passwords.loadbalancer.server.port=80"

      - "traefik.http.routers.passwords-api.rule=Host(`pass.${DOMAIN}`) && PathRegexp(`(^/api.*)|(^/identity.*)|(^/#/send.*)|(^/notifications.*)|(^/images.*)|(^.*\\.json)|(^/icons.*)`)" # https://www.reddit.com/r/selfhosted/comments/1knli8i/comment/msmhhy2/?context=3
      - "traefik.http.routers.passwords-api.entrypoints=websecure"
      - "traefik.http.routers.passwords-api.tls.certresolver=myresolver"
      - "traefik.http.services.passwords-api.loadbalancer.server.port=80"
      
      - docker-volume-backup.stop-during-backup=backup

When using multiple Traefik routers and services in labels, you need to assign them:

    labels:
      - "traefik.enable=true"

      - "traefik.http.routers.passwords.rule=Host(`pass.${DOMAIN}`)"
      - "traefik.http.routers.passwords.entrypoints=localonly"
      - "traefik.http.routers.passwords.tls.certresolver=myresolver"
      - "traefik.http.routers.passwords.service=passwords"
      - "traefik.http.services.passwords.loadbalancer.server.port=80"

      - "traefik.http.routers.passwords-api.rule=Host(`pass.${DOMAIN}`) && PathRegexp(`(^/api.*)|(^/identity.*)|(^/#/send.*)|(^/notifications.*)|(^/images.*)|(^.*\\.json)|(^/icons.*)`)" # https://www.reddit.com/r/selfhosted/comments/1knli8i/comment/msmhhy2/?context=3
      - "traefik.http.routers.passwords-api.entrypoints=websecure"
      - "traefik.http.routers.passwords-api.tls.certresolver=myresolver"
      - "traefik.http.routers.passwords-api.service=passwords-api"
      - "traefik.http.services.passwords-api.loadbalancer.server.port=80"

[/quote]

Thank you very much @bluepuma77

I Tried it. Im still getting the same exact error.

Gonna read the service documentation, the answer may be there.

2025-05-17T15:57:42Z ERR Router passwords-api cannot be linked automatically with multiple Services: ["passwords-api" "passwords"] providerName=docker routerName=passwords-api
2025-05-17T15:57:42Z ERR Router passwords cannot be linked automatically with multiple Services: ["passwords-api" "passwords"] providerName=docker routerName=passwords

EDIT

Issue was not that, it was the local dns entry and the reverse nat of the router.... fixed that, refreshed dns cache on client and server, restarted the docker stack, then it worked. Thanks.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.