Traefik and Grafana Get 404 page not found

Hey I'm using docker on a raspberry pi.

I started with a whoami Service. Everythings works fine for. I could reach the service via :
http://IP-Rasberry/whoami

So I also will reach my grafana dashboard in the same way :
http://IP-Rasberry/grafana

Here is my docker-compose.yml

version: '3.3'

services:

  ################################################
  # TRAEFIK SERVICE
  ################################################
  traefik:
    image: traefik:latest
    container_name: traefik
    restart: always
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    command:
      - "--log.level=INFO"
      - "--api.insecure=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entryPoints.web.address=:80"
      - "--entryPoints.websecure.address=:443"

  ################################################
  # TEST SERVICE
  ################################################
  whoami:
    image: containous/whoami
    container_name: test-whoami
    restart: always
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Path(`/whoami`)"
      - "traefik.http.routers.whoami.entrypoints=web"
    depends_on:
      - traefik

  ################################################
  # GRAFANA SERVICE
  ################################################
  grafana:
    image: grafana/grafana
    container_name: grafana
    restart: always
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana.rule= PathPrefix(`/grafana`)"
      - "traefik.http.routers.grafana.entrypoints=web"
      - "traefik.http.routers.grafana.service=grafana"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"
    user: "${UID}:${GID}"
    volumes:
      - /home/pi/docker/volumes/grafana:/var/lib/grafana:rw
    depends_on:
      - traefik

But when i call http://IP-Rasberry/grafana I got 404 page not found

Has anybody an idea ?

You can’t just add a prefix to a web service that is listening on pre-defined URL path. Even if you strip it in middleware, this usually does not work because web apps send responses with fixed absolute paths (redirect, scripts, images, links).

Use another hostname/sub-domain instead.

Tank for your response.
I tried this without success :

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana.rule= Host(`192.168.2.136`) && PathPrefix(`/grafana/`)"
      - "traefik.http.middlewares.grafana.stripprefix.prefixes=/grafana"
      - "traefik.http.routers.grafana.entrypoints=web"
      - "traefik.http.routers.grafana.service=grafana"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"

192.168.2.136 is the address of the raspberry pi.
I'm not sure if this is correct ?

What is wrong

Again: web-apps don't simply work with a path prefix. This only works when you can specifically set a "base path" or similar within the web app. Use a hostname/sub-domain instead.

  labels:
    - "traefik.enable=true"
    - "traefik.http.routers.grafana.rule=Host(`grafana.mydomain`)
    - "traefik.http.routers.grafana.entrypoints=web"
    - "traefik.http.routers.grafana.service=grafana"
    - "traefik.http.services.grafana.loadbalancer.server.port=3000"

You can usually create internal domains using hosts file or on your Internet router.

Thanks for your answer. I add these to my host file :
192.168.2.136 whoami.docker-raspberry grafana.docker-raspberry wiki.docker-raspberry
I updatet my docker file :


  ################################################
  # TEST SERVICE
  ################################################
  whoami:
    image: containous/whoami
    container_name: test-whoami
    restart: always
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.docker-raspberry`)"
      - "traefik.http.routers.whoami.entrypoints=web"
    depends_on:
      - traefik

  ################################################
  # GRAFANA SERVICE
  ################################################
  grafana:
    image: grafana/grafana
    container_name: grafana
    restart: always
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana.rule=Host(`grafana.docker-raspberry`)"
      - "traefik.http.routers.grafana.entrypoints=web"
    user: "${UID}:${GID}"
    volumes:
      - /home/pi/docker/volumes/grafana:/var/lib/grafana:rw
    depends_on:
      - traefik

Everthings works ! But one last question. If I want to reach my grafana service from the internet I need a subdomain. But my fritz box doesn't support it. Thats the reason why I used Paths.
Is there a possibility to redirect from my fritzbox upblic address e.g myfritzbox.public/grafana to grafana.docker-raspberry

You can assign a sub-domains a CNAME and point it to another domain (like Fritz Dyndns, instead of a fixed IP). That way it always points to the current home IP. Also check providers like http://www.duckdns.org.