Treafik and Grafana

HI guys,

I got trouble with running the grafana behind the traefik in docker. I don't actually know, whether the problem is on the grafana side or on the traefik side. Anyway, here is my docker compose code:

version: "3.3"

services:

  traefik:
    image: "traefik:v2.4"
    container_name: "traefik"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.secureweb.address=:443"
      - "--entrypoints.local.address=:8585"
       - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
      #- "--certificatesresolvers.myhttpchallenge.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
      - "--certificatesresolvers.myresolver.acme.email=mail@mail.com"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
      - "8585:8585"
    volumes:

      - "/var/run/docker.sock:/var/run/docker.sock:ro"

 grafana:
    image: "grafana/grafana"
    container_name: "grafana"
    volumes:
      - "./grafana.ini:/etc/grafana/grafana.ini"
      - "./datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml"
    expose:
      - "3000"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana-internal.rule=Host(`valid.domain`) && Path(`/monitor`)"
      - "traefik.http.routers.grafana-internal.entrypoints=local"
      - "traefik.http.routers.grafana-internal.service=grafana-service"
      - "traefik.http.services.grafana-service.loadbalancer.server.port=3000"

grafana.ini file is left as default - only serve_from_sub_path is set to true (according to the many discussion threads I have found). If I go valid.domain/monitor it redirects me to the valid.domain/login and then gives me 404. Is there some check with this redirection? or can you see another obvious problem?

Thanks a milion guys

onbartik

EDIT: Pay no mind to the cert part in the traefik config. This file also contains some other container setups in real which use the cert features. But I omitted it as it has no impact on the grafana - I hope so.

If you're using Path, you also need to set Grafana to that as base url.