Traefik Dashboard throws 404 error for /api routes

My config is:

services:
  traefik:
    image: traefik:v3.0
    ports:
      - 80:80
      - 443:443
    networks:
      - proxynet
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - letsencrypt:/letsencrypt
    command:
      - --api.dashboard=true
      - --log.level=INFO
      - --accesslog=true
      - --providers.docker.network=proxynet
      - --providers.docker.exposedByDefault=false
      - --entrypoints.web.address=:80
      - --entrypoints.web.http.redirections.entrypoint.to=websecure
      - --entryPoints.web.http.redirections.entrypoint.scheme=https
      - --entrypoints.websecure.address=:443
      - --entrypoints.websecure.asDefault=true
      - --entrypoints.websecure.http.tls.certresolver=le
      - --certificatesresolvers.le.acme.email=perzhul.works@gmail.com
      - --certificatesresolvers.le.acme.tlschallenge=true
      - --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
      - --certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory

    labels:
      - traefik.enable=true
      - traefik.http.routers.mydashboard.rule=Host(`traefik.mydomain.pro`) || PathPrefix(`/api`) || PathPrefix(`/dashboard`)
      - traefik.http.routers.mydashboard.service=api@internal

networks:
  proxynet:
    name: proxynet
    external: true

volumes:
  letsencrypt:
    name: letsencrypt

when im trying to access the dashboard, the page loads but throws 404 errors for the following routes

I even did docker prune -a before trying to setup traefik again. In the logs I can see this:

2024-06-18T13:27:33Z INF Traefik version 3.0.2 built on 2024-06-10T14:38:51Z version=3.0.2
2024-06-18T13:27:33Z INF 
Stats collection is disabled.
Help us improve Traefik by turning this feature on :)
More details on: https://doc.traefik.io/traefik/contributing/data-collection/

2024-06-18T13:27:33Z INF Starting provider aggregator aggregator.ProviderAggregator
2024-06-18T13:27:33Z INF Starting provider *acme.ChallengeTLSALPN
2024-06-18T13:27:33Z INF Starting provider *traefik.Provider
2024-06-18T13:27:33Z INF Starting provider *docker.Provider
2024-06-18T13:27:33Z INF Starting provider *acme.Provider
2024-06-18T13:27:33Z INF Testing certificate renew... acmeCA=https://acme-staging-v02.api.letsencrypt.org/directory providerName=le.acme
2024-06-18T13:27:55Z ERR Unable to obtain ACME certificate for domains error="unable to generate a certificate for the domains [traefik.mydomain.pro]: error: one or more domains had a problem:\n[traefik.mydomain.pro] acme: error: 403 :: urn:ietf:params:acme:error:unauthorized :: Cannot negotiate ALPN protocol \"acme-tls/1\" for tls-alpn-01 challenge\n" ACME CA=https://acme-staging-v02.api.letsencrypt.org/directory acmeCA=https://acme-staging-v02.api.letsencrypt.org/directory domains=["traefik.mydomain.pro"] providerName=le.acme routerName=mydashboard@docker rule=Host(`traefik.mydomain.pro`)

Looks similar to simple Traefik example, I can’t spot the error yet.

The domain and sub-domain point to your Traefik IP?

Note that the rule logic is wrong, it should be:

Host() && ( PathP() || PathP() )

But it should still work with the current config.

1 Like

Thank you for your reply. I found that the problem might not be what I originally thought it to be. The thing is, I can see other tabs other than the main one on the dashboard and see the services and so on. But when I use one of the other subdomains I have, it works just fine and dashboard loads with no problem. Then also I have this weird bug that when I run one of my other containers which has it's own router and other service, it somehow points to the traefik container and shows the dashboard with no bugs even though I don't want it. I'm dazed and confuzed

Make sure to get the router rule logic right and use different router names in labels for every service/container.

1 Like