Hi all,
i've been trying to wrap my head around traefik for the past week and its been a real slog... anyway, i was looking at the dashboard router rules in the documentation, which says that the router rule must match /api and /dashboard.
In the example, the code adds the traefik subdomain as well as the two pathPrefixes:
- "traefik.http.routers.dashboard.rule=Host(
traefik.example.com) && (PathPrefix(
/api) || PathPrefix(
/dashboard))"
When i try to implement this configuration, however, my log goes crazy because the rule seems to be routing to itself, causing an endless loop. I would like to have the option of accessing my dashboard through the subdomain as well as the /dashboard prefix though. Is there something wrong with my code, or is the example not up to date anymore?
Try posting the full config. Static, Dynamic and Cli args used.
This is a rule I have applied many time myself, so the problem is likely elsewhere.
hey cakiwi, thanks for your reply.
maybe its because i'm not using the right syntax for CLI commands? here is the full compose:
version: "3.7"
services:
traefik:
image: "traefik:latest"
command:
- --entrypoints.web.address=:80
- --providers.docker
- --api.insecure # Don't do that in production
labels:
- traefik.http.routers.api.rule="Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
- "traefik.http.routers.api.service=api@internal"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
my-app:
image: containous/whoami
labels:
- traefik.http.routers.my-app.rule=Host(`who.example.com`)
So you have api.insecure
and you are also trying to define your own router for the dashboard.
api.insecure creates a set of rules/redirects and an entrypoint. As your router does not specify an entrypoint is will also bind to 8080 so the rules are likely in conflict for good operation of the api/dashboard.
Remove the api.insecure
parameter and you should fare better.