Traefik ignores containers with two routers?

I am using docker compose to set up my container, there are two sets of routes, one for internal traffic and one for external traffic. These are separated because I intend to add a rule for a prefix and prefix stripping to the external traffic route. Either route will work if I comment out the other one, but both routes will not work at the same time. They both have different names. According to the documentation, this should work. I am using Traefik 3.6.

labels:
  - "traefik.enable=true"
  # Local access, host only
  - "traefik.http.routers.foundry14lan.rule=Host(\`vtt.homelab.lan\`)"
  - "traefik.http.routers.foundry14lan.entrypoints=websecure"
  - "traefik.http.routers.foundry14lan.tls=true"
  - "traefik.http.services.foundry14lan.loadbalancer.server.port=30000"
  # External access, https, with path that needs to be stripped
  - "traefik.http.routers.foundry14web.rule=Host(\`<redacted>\`)"
  - "traefik.http.routers.foundry14web.entrypoints=websecure"
  - "traefik.http.routers.foundry14web.tls=true"
  - "traefik.http.services.foundry14web.loadbalancer.server.port=30000"

If I comment out either set of rules, the router shows up as expected in the dashboard and the rules work. If both sets of rules are in, neither shows up in the dashboard and the routes give a 404 error.

When using multiple Traefik routers and services in labels, you need to assign the service to the router. This is not done automatically because they use the same name.

The backslashes seem wrong.

Note that prefix and stripPrefix usually doesn’t work, as web apps mostly respond with absolute path for dependencies like scripts and images. Sub-domains are best practice.

Thanks! Assigning the service did the trick!

I’m not sure where the backslashes came from, they aren’t in the original docker-compose file. Maybe a result of the copy-paste?

Unfortunately, I am using a DDNS that is provided by my router, so subdomains are not an option. I was experimenting with the prefix and stripPrefix trying to get the right combo, I ended up getting rid of stripPrefix and it now seems to be working as expected. The container itself has a subdirectory mode, almost as if they anticipated this type of scenario.

Thanks for the help!

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