404 page not found with whoami example

I'm trying out the new 2.0 GA of Traefik but I'm having trouble getting the most basic of examples working. After reading the documentation and trying different things out for several hours, now I'm here asking for some guidance. I can access the dashboard and raw api info, and I see the whoami router in the dashboard. But when I go to whoami.development.local, I just get 404 page not found. What am I missing?

traefik.yml deployed using

docker stack deploy traefik -c traefik.yml
version: '3.7'

services:

  traefik:
    image: traefik:v2.0
    command:
      - "--log.level=DEBUG"
      - "--log.filepath=/traefik.log"
      - "--log.format=json"
      - "--api=true"
      - "--api.dashboard=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=true"
      - "--entrypoints.http.address=:80"
      - "--entrypoints.https.address=:443"
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=traefik-public"
      - "traefik.http.routers.traefik.rule=Host(`traefik.development.local`)"
      - "traefik.http.routers.traefik.entrypoints=https"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefikloadbalancer.server.port=8080"
    networks:
      - traefik-public
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
#      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./ssl:/etc/traefik/ssl
      - ./logs/traefik.log:/traefik.log
    ports:
      - "80:80"
      - "8080:8080"
      - "443:443"
    deploy:
      placement:
        constraints:
          - node.role == manager
      update_config:
        order: start-first		# get new container running first before removing old, for less downtime
      rollback_config:
        order: start-first		# get new container running first before removing old, for less downtime
      restart_policy:
        condition: any

networks:

  traefik-public:
    driver: overlay
    name: traefik-public

whoami.yml deployed using

docker stack deploy whoami -c whoami.yml
version: '3.7'

services:
  whoami:
    image: containous/whoami
    networks:
      - traefik-public
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.docker.network=traefik-public"
        - "traefik.http.routers.whoami.entrypoints=http"
        - "traefik.http.routers.whoami.rule=Host(`whoami.development.local`)"

networks:
  traefik-public:
    external: true
    name: traefik-public

Hello, linucksrox,

To start with you do not seem to enable swarm mode for traefik in your configuration.

Also did you try looking at the log file? I used your configuration, added enabling of swarm mode, and had a glance in the log and I got a lot of records similar to

{"container":"whoami_whoami-asdum4ygd2b67wevs4b3dcoe1","level":"error","msg":"port is missing","providerName":"docker","time":"2019-09-23T03:12:08Z"}

Which indicates that traefik does not know to what port to route your requests. I then looked up the swarm example in the documentation, and bingo, it has an explicit line specifying the port number. Once I added that (modifying it to be in line with the rest of your example), lo and behold I got a correct response from whoami instead of the 404.

Hope that helps.

1 Like

Thanks @zespri! That was it, I didn't enable swarm mode and I needed to specify the port for the service. It's working how I want now!

1 Like