Pihole v6 webgui behind Traefik

Have just spent the last three and a half hours tearing my hair out trying to make this work. Am migrating from v5.

If I leave the default ports alone, trying to hit the url times out. If I change the port of Pihole via a FTLCONF_webserver_port Traefik cannot see Pihole and exposing the changed port does nothing – as in it doesn't appear as exposed when running docker ps -a.

I'm at a loss as to where to go here, other than to revert back to v5.

Docker compose snippet:

pihole:
    image: pihole/pihole:latest
    container_name: pihole
    hostname: pihole
    networks:
      network_name:
        ipv4_address: 10.5.0.3
    dns:
      - 127.0.0.1
      - 1.1.1.1
    ports:
      - 53:53/tcp
      - 53:53/udp
    environment:
      TZ: Cont/City
      FTLCONF_dns_listeningMode: all
      FTLCONF_dns_upstreams: 10.5.0.4#5053
      FTLCONF_webserver_domain: "pihole.domain.com"
      FTLCONF_webserver_interface_theme: default-auto
      FTLCONF_webserver_interface_boxed: false
    volumes:
      - "./pihole/etc-pihole:/etc/pihole"
      - "./pihole/etc-dnsmasq.d:/etc/dnsmasq.d"
    cap_add:
      - NET_ADMIN
    depends_on:
     - cloudflared
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.pihole.tls=true"
      - "traefik.http.routers.pihole.rule=Host(`pihole.domain.com`)"
      - "traefik.http.middlewares.pihole-redirect.redirectregex.regex=^https://pihole.domain.com/?$$"
      - "traefik.http.middlewares.pihole-redirect.redirectregex.replacement=https://pihole.domain.com/admin"
    restart: unless-stopped

Please share the output of:

docker ps
docker image ls pihole/pihole

Thanks for the quick reply.

Output of docker compose ps -a:

NAME                COMMAND                  SERVICE             STATUS               PORTS
cloudflared         "/usr/local/bin/clou…"   cloudflared         running (healthy)   49312/tcp
dhcp-helper         "dhcp-helper -n -s 1…"   dhcp-helper         running              
pihole              "start.sh"               pihole              running (healthy)   0.0.0.0:53->53/tcp, 0.0.0.0:53->53/udp, :::53->53/tcp, :::53->53/udp
traefik             "/entrypoint.sh trae…"   traefik             running              0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8080->8080/tcp, :::80->80/tcp, :::443->443/tcp, :::8080->8080/tcp

Image is latest:

pihole              pihole/pihole             latest              cf5e7ddfcd9a        106MB

latest is just the tag as present at the time the image was downloaded, so you could still have been running from a v5 image.
But size as well as the COMMAND from the container list suggest it's indeed a v6 image and container.

Contrary to your description, your docker compose is void of any FTLCONF_webserver_port or ports declarations for port 80.

What's your container's network mode?

When that mode is allowing your container to declare ports, as your compose suggests, there would be not need to adjust FTLCONF_webserver_port.

Did you try having Docker map port 80 yet?

    ports:
      - 53:53/tcp
      - 53:53/udp
      - 8081:80/tcp

Thanks again for the reply – can't @ you as I'm new here :slight_smile:

Sorry, the config I posted was the last config I'd tried, i.e. not specifying a port, running with the defaults of 80,443. Specifying the defaults under port would error as traefik already occupies those ports on the host, so my hope was that I'd be able to get away with only exposing the ports on the docker network vs mapping to host ports.

I've just tried FTLCONF_webserver_port: 8089 now and… appear to have gotten it working. It didn't seem to work on port 8081, however this works. I have no idea why if I'm honest, but I'll take it :grinning:

Thanks for your help, it's appreciated.

Updated compose snippet in case it helps anyone else:

  pihole:
    image: pihole/pihole:latest
    container_name: pihole
    hostname: pihole
    networks:
      network_name:
        ipv4_address: 10.5.0.3
    dns:
      - 127.0.0.1
      - 1.1.1.1
    ports:
      - 53:53/tcp
      - 53:53/udp
    expose:
      - 8089
    environment:
      TZ: Europe/London
      FTLCONF_dns_listeningMode: all
      FTLCONF_dns_upstreams: 10.5.0.4#5053
      FTLCONF_webserver_domain: "pihole.domain.com"
      FTLCONF_webserver_interface_theme: default-auto
      FTLCONF_webserver_interface_boxed: false
      FTLCONF_webserver_port: 8089
    volumes:
      - "./pihole/etc-pihole:/etc/pihole"
      - "./pihole/etc-dnsmasq.d:/etc/dnsmasq.d"
    cap_add:
      - NET_ADMIN
    depends_on:
     - cloudflared
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.pihole.tls=true"
      - "traefik.http.routers.pihole.rule=Host(`pihole.domain.com`)"
      - "traefik.http.middlewares.pihole-redirect.redirectregex.regex=^https://pihole.domain.com/?$$"
      - "traefik.http.middlewares.pihole-redirect.redirectregex.replacement=https://pihole.domain.com/admin"
      - "traefik.http.services.pihole.loadbalancer.server.port=8089"
      - "traefik.http.services.pihole.loadbalancer.passhostheader=true"
    restart: unless-stopped

I see no reason why mapping - 8089:80/tcp should not have worked, without the need to also set FTLCONF_webserver_port.

The correct variable is FTLCONF_webserver_api_port.

I made a confusion... The variable you used is correct.