404 on Dashboard

Hello,

Not able to understand why I get 404 when trying to reach Traefik v2 on 443 80 or even 8080
Even locally I get the 404 Page not found.
Let me know if this is the correct way. I followed a guide, since its the first time I use Traefik.

Let me know if anything else is needed.

Thanks

I attached my traefik docker-compose

version: "3.7"

########################### NETWORKS
networks:
  t2_proxy:
    external:
      name: t2_proxy
  default:
    driver: bridge

########################### SERVICES
services:
# All services / apps go below this line

# Traefik 2 - Reverse Proxy
  traefik:
    container_name: traefik
    image: traefik:chevrotin # the chevrotin tag refers to v2.2.x
    restart: unless-stopped
    command: # CLI arguments
      - --global.checkNewVersion=true
      - --global.sendAnonymousUsage=true
      - --entryPoints.http.address=:80
      - --entryPoints.https.address=:443
        # Allow these IPs to set the X-Forwarded-* headers - Cloudflare IPs: https://www.cloudflare.com/ips/
      - --entrypoints.https.forwardedHeaders.trustedIPs=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/12,172.64.0.0/13,131.0.72.0/22
      - --entryPoints.traefik.address=:8080
      - --api=true
#      - --api.insecure=true
#      - --serversTransport.insecureSkipVerify=true
      - --log=true
      - --log.level=DEBUG # (Default: error) DEBUG, INFO, WARN, ERROR, FATAL, PANIC
      - --accessLog=true
      - --accessLog.filePath=/traefik.log
      - --accessLog.bufferingSize=100 # Configuring a buffer of 100 lines
      - --accessLog.filters.statusCodes=400-499
      - --providers.docker=true
      - --providers.docker.endpoint=unix:///var/run/docker.sock
      - --providers.docker.defaultrule=Host(`{{ index .Labels "com.docker.compose.service" }}.$DOMAINNAME`)
      - --providers.docker.exposedByDefault=false
      - --providers.docker.network=t2_proxy
      - --providers.docker.swarmMode=false
      - --providers.file.directory=/rules # Load dynamic configuration from one or more .toml or .yml files in a directory.
#      - --providers.file.filename=/path/to/file # Load dynamic configuration from a file.
      - --providers.file.watch=true # Only works on top level files in the rules folder
      - --certificatesResolvers.dns-cloudflare.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory # LetsEncrypt Staging Server - uncomment when testing
      - --certificatesResolvers.dns-cloudflare.acme.email=$CLOUDFLARE_EMAIL
      - --certificatesResolvers.dns-cloudflare.acme.storage=/acme.json
      - --certificatesResolvers.dns-cloudflare.acme.dnsChallenge.provider=cloudflare
      - --certificatesResolvers.dns-cloudflare.acme.dnsChallenge.resolvers=1.1.1.1:53,1.0.0.1:53
    networks:
      t2_proxy:
        ipv4_address: 192.168.90.254 # You can specify a static IP
#    networks:
#      - t2_proxy
    security_opt:
      - no-new-privileges:true
    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: host
      - target: 443
        published: 443
        protocol: tcp
        mode: host
      - target: 8080
        published: 8080
        protocol: tcp
        mode: host
    volumes:
      - $USERDIR/docker/traefik2/rules:/rules 
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - $USERDIR/docker/traefik2/acme/acme.json:/acme.json 
      - $USERDIR/docker/traefik2/traefik.log:/traefik.log 
      - $USERDIR/docker/shared:/shared
    environment:
      - CF_API_EMAIL=$CLOUDFLARE_EMAIL
      - CF_API_KEY=$CLOUDFLARE_API_KEY
    labels:
      - "traefik.enable=true"
      # HTTP-to-HTTPS Redirect
      - "traefik.http.routers.http-catchall.entrypoints=http"
      - "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
      # HTTP Routers
      - "traefik.http.routers.traefik-rtr.entrypoints=https"
      - "traefik.http.routers.traefik-rtr.rule=Host(`traefik.$DOMAINNAME`)"
      - "traefik.http.routers.traefik-rtr.tls=true"
      - "traefik.http.routers.traefik-rtr.tls.certresolver=dns-cloudflare" # Comment out this line after first run of traefik to force the use of wildcard certs
      - "traefik.http.routers.traefik-rtr.tls.domains[0].main=$DOMAINNAME"
      - "traefik.http.routers.traefik-rtr.tls.domains[0].sans=*.$DOMAINNAME"
#      - "traefik.http.routers.traefik-rtr.tls.domains[1].main=$SECONDDOMAINNAME" # Pulls main cert for second domain
#      - "traefik.http.routers.traefik-rtr.tls.domains[1].sans=*.$SECONDDOMAINNAME" # Pulls wildcard cert for second domain
      ## Services - API
      - "traefik.http.routers.traefik-rtr.service=api@internal"
      ## Middlewares
      - "traefik.http.routers.traefik-rtr.middlewares=middlewares-basic-auth@file" 

and the middlewares.toml

[http.middlewares]
  [http.middlewares.middlewares-basic-auth]
    [http.middlewares.middlewares-basic-auth.basicAuth]
#      username=user, password=mystrongpassword (listed below after hashing)
#      users = [
#        "user:$apr1$bvj3f2o0$/01DGlduxK4AqRsTwHnvc1",
#      ]
      realm = "Traefik2 Basic Auth"
      usersFile = "/shared/.htpasswd" #be sure to mount the volume through docker-compose.yml

How are you testing ?

I would docker inspect your container and check the labels. Incorrectly setting/exporting DOMAINNAME could result in the route not being matched.

Check the logs for errors also.

1 Like

Thanks Ill start with that.
In regards of the logs... They not always show data...
Is there specific logs other than the access ones?

Thanks

Yes. docker logs your_container_name unless you are doing something special with your container logs.

Like any well behaved container it logs to stdout.

Thanks... I'm in the learning curve and a bit lost with all the different things to learn while I set everything.
I read and tried different things before I posted mine. Thanks for the tips. Ill look around and report!

I did some validation and even reviewed all the labes and config.
Also tried to simplify the *.yml using the ones from this blog:

https://containo.us/blog/traefik-2-0-docker-101-fc2893944b9d/

Same issue receiving an 404 page not found simply using the following yml

version: "3.3"

services:
  traefik:
    image: "traefik:v2.0.1"
    command:
      - --entrypoints.web.address=:80
      - --providers.docker
      - --api.insecure
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  my-app:
    image: containous/whoami:v1.3.0

# Dashboard (https://localhost:8080)

And logs don't show anything.

so back to square one

The uri to access the dashboard requires the path and a trailing slash.

http://localhost:8080/dashboard/

Yes, with or without the slash I get a 404 or a Problem loading page.

I'm planning on building a scratch image just to restart from blank and see if I did something wrong.
Any guide I could follow to be sure I don't miss anything? Thanks

I ran the simple compose file verbatim:

 curl -i 127.0.0.1:8080/
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /dashboard/
Date: Wed, 20 May 2020 11:20:52 GMT
Content-Length: 34

<a href="/dashboard/">Found</a>.

I forgot that in insecure more that localhost:8080/ will redirect to the dashboard.also.

I ran the command and yes I get the following
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /dashboard/
Date: Wed, 20 May 2020 15:49:51 GMT
Content-Length: 34

You should be able to hit that with a browser too and see the Traefik Dashboard.

It works locally... but not remotely

I was reviewing different documents and I have a question.
Could it be related to the way my Domain is setup?
My domain is pointing to cloudflare and cloudflare pointing to my server.
Is this right?

I was able to confirm my domain pointing to my server. All good.
When I reach Traefik dashboard on 8080 all working
But when reaching 81 I get the 404.

This is my traefik file

version: "3.3"

services:
  traefik:
    image: "traefik:v2.0.1"
    command:
      - --entrypoints.web.address=:81
      - --providers.docker
      - --api.insecure
    ports:
      - "81:81"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  my-app:
    image: containous/whoami:v1.3.0

# Dashboard (https://localhost:8080)

The results from the curl command:

HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Fri, 22 May 2020 03:33:45 GMT
Content-Length: 19

404 page not found

I'm I missing something?

Thanks

my-app does not have a routing rule. At the moment it will be bound to all entrypoints (web port 81) and have the default routing rule Host(`{{ normalize .Name }}`) ( this is still magic to me)

You should add a rule to my-app that will match. Either Host or PathPrefix would work.

https://docs.traefik.io/getting-started/quick-start/#traefik-detects-new-services-and-creates-the-route-for-you