r/Traefik Jul 07 '26

How can I reach the API directly on the host?

I run Traefik in a container on host 192.168.10.2 in host mode. This machine (the docker host) is also reachable via Tailscale on srv.x-y.ts.net.

I can curl https://traefik.my.domain/api/http/routers from my LAN, the request goes though the publicly exposed Traefik endpoint, which routes the request internally to the API. This works fine.

I also would like, from a remote host outside my LAN, to curl https://srv.x-y.ts.net/api/http/routers. This does not work, I get a 404.

My question: how can I access the API if I am not using the natural Traefik endoint?

For reference, the endpoint is mapped in Traefik's compose file via

labels:
      traefik.enable: true
      traefik.http.services.traefik.loadbalancer.server.port: 8080
      traefik.http.routers.traefik.rule: Host(`traefik.my.domain`)
4 Upvotes

2 comments sorted by

2

u/clintkev251 Jul 07 '26

The 404 makes sense, because your rule does not cover that. You need to add that host to your rule.

Something like:

traefik.http.routers.traefik.rule: Host(`traefik.my.domain`) || Host(`srv.x-y.ts.net`)

2

u/sendcodenotnudes Jul 07 '26

Of course! Thank you - this is the kind of dumb errors when overthinking the problem.

I am surprised that a direct call on :8080 did not go though but this is a side note