[Traefik 2.4.8] Pihole is getting 404 page not found

Hello,

I am trying to set up my Pihole via Traefik but I am getting 404 page not found

Traefic docker-compose.yaml

version: '3'

services:
  traefik:
    image: traefik:latest
    container_name: traefik
    restart: unless-stopped
#    security_opt:
#      - no-new-privileges:true
    ports:
      # Web
      - 80:80
      - 443:443
    networks:
      - web
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # Map the static conf into the container
      - ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
      # Map the dynamic conf into the container
      - ./traefik/config.yml:/etc/traefik/config.yml:ro
      # Map the certificats into the container
      - ./certs:/etc/certs:ro
      # Map the usersfile into the container
      - ./usersfile:/etc/traefik/usersfile
    labels:
      # Enable this container to be mapped by traefik
      # For more information, see: https://docs.traefik.io/providers/docker/#exposedbydefault
      - "traefik.enable=true"
      # Use "traefik" router configuration defined into the dynamic config file: ./traefik/config.yml
      - "traefik.http.routers.traefik=true"
      - "traefik.http.middlewares.to-https.redirectscheme.scheme=https"
#      - "traefik.http.routers.to-https.rule=HostRegexp(`{host:.+}`)"
#      - "traefik.http.routers.to-https.entrypoints=http"
#      - "traefik.http.routers.to-https.middlewares=to-https"

networks:
  web:
    external: true

Traefik config files:

traefik.yml

global:
  sendAnonymousUsage: false

api:
  dashboard: true
#  insecure: true

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    watch: true
    network: web

  file:
    filename: /etc/traefik/config.yml
    watch: true

log:
  level: INFO
  format: common

entryPoints:
  http:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: https
          scheme: https

  https:
    address: ":443"

dynamic file - config.yml

http:
  routers:
    traefik:
      rule: "Host(`traefik.domain.com`)"
      service: "api@internal"
      middlewares: "auth"
      tls:
        domains:
          - main: "domain.com"
            sans:
              - "*.domain.com"
          - main: "domain.com"
            sans:
              - "*.domain.com"
  middlewares:
    auth:
      basicAuth:
        usersFile: "/etc/traefik/usersfile"

tls:
  certificates:
    - certFile: "/etc/certs/fullchain.pem"
      keyFile: "/etc/certs/privkey.pem"

Pihole docker-compose.yml file

 pi-hole:
    container_name: pi-hole
    image: pihole/pihole:v5.7
    hostname: pihole
    restart: unless-stopped
    # Web panel will be at http://<your pi's ip>:8000 Set your devices or routers DNS to your pi's ip
    ports:
      - "8000:80/tcp"
      - "53:53/tcp"
      - "53:53/udp"
    environment:
      - ServerIP=10.10.50.3
      - DNS1='10.10.50.2#5054'
      - DNS2=''
      - IPv6=false
      - TZ=UTC
      - DNSMASQ_LISTENING=all
    # Replace PASSWORD with a password for the pihole admin panel
      - WEBPASSWORD=<PASSWORD>
    networks:
      pihole:
        ipv4_address: 10.10.50.3
      web:
    # Config files are bound to /home/pi/pihone on your raspberrypi, if your using a different device other than a raspberry pi change it to somewhere else
    volumes:
      - './etc-pihole/:/etc/pihole/'
      - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
      - './youTube_ads_4_pi-hole/:/root/youTube_ads_4_pi-hole/'
    # This is for the pihole container dns you dont need to change it
    dns:
      - 127.0.0.1
      - 1.1.1.1
    cap_add:
      - NET_ADMIN
    labels:
      - traefik.enable=true
      - traefik.docker.network=web
      - traefik.http.middlewares.pi-hole.redirectscheme.scheme=https
      - traefik.http.middlewares.https_redirect.redirectscheme.permanent=true
      - traefik.http.routers.pi-hole.rule=Host(`pihole.domain.com`) && PathPrefix(`/admin`)
#      - traefik.frontend.rule=HostRegexp:pihole.domain.com,{catchall:.*}
      - traefik.http.routers.pi-hole.tls=true
      - traefik.port=8000
      - ofelia.enabled=true
      #ofelia.job-exec.youTube_ads_4_pi.schedule: "@every 3h"
      #ofelia.job-exec.youTube_ads_4_pi.command: "/root/youTube_ads_4_pi-hole/youtube.sh"
      - ofelia.job-exec.pihole_update_gravity.schedule="@every 4h"
      - ofelia.job-exec.pihole_update_gravity.command="pihole -g"

networks:
  pihole:
    driver: bridge
    ipam:
     config:
       - subnet: 10.10.50.0/27
  web:
#   external: true

I've solved the issue by myself, the problem was that I've put port 8080 for loadbalancer.server.port, not the container port 80

pihole:
.....
  ports:
    - "8000:80"

the right label is:

- traefik.http.services.pi-hole.loadbalancer.server.port=80

at the moment i am using these lables below:

    labels:
      - traefik.enable=true
      - traefik.http.middlewares.pi-hole.redirectscheme.scheme=https
      - traefik.http.routers.pi-hole.rule=Host(`pihole.domain.com)
      - traefik.http.routers.pi-hole.tls=true
      - traefik.http.services.pi-hole.loadbalancer.server.port=80
1 Like

I was just writing a reply. :+1: