PiHole behind Traefik

I'm currently trying to integrate pihole in a project with some other services behind the Reverse Proxy TRAEFIK in docker, for this project I'm using a simple free DNS domain taken from DuckDNS, so I can't really create subdomains.

I would like to know if it is possible (and if someone succeed) to access pihole dashboard with a subfolder like my.domain/pihole/admin rather than the classic subdomain like pihole.my.domain/admin.

I try with pathprefix, pathprefixstrip and path in the labels section of my docker-compose but did not succeed yet. For other services like traefik dashboard or portainer it works without problem.

Thanks for your answers.

The web interface does not (yet) support proxying in this way. Wait until the new web interface and API are released: GitHub - pi-hole/web: Pi-hole Web Interface for viewing stats and managing your Pi-hole

1 Like

Has this changed in the last few years - is this supported now?

(I tried using pathprefix and it didn't work, but maybe there's some other configuration option?)

If not, where should I file a feature request? The repo linked in the previous answer doesn't exist anymore.

What do you have for your Traefik dynamic configuration?


I haven't tried it myself yet with Pihole, but something like this should work (here for /admin; you might want to do the same for other locations) :

  - "traefik.enable=true"
  - "traefik.http.routers.piholeweb.entrypoints=web"
  - "traefik.http.routers.piholeweb.rule=PathPrefix(`/admin/`)"
  - "traefik.http.middlewares.piholeweb-stripprefix.stripprefix.prefixes=/admin"
  - "traefik.http.routers.piholeweb.middlewares=piholeweb-stripprefix"
  - "traefik.http.services.piholeweb.loadbalancer.server.port=80"

Disclaimer : I'm not very familiar with lighttpd. It seems backend location is '/', which point to website hosted on /var/www/html, so ^/admin/.* queries should match this traefik rule, and then /admin prefix is stripped, so you end up on this (existing) location : '/'.

If you don't strip prefix, you end up in this lighttpd rule :

# If the URL starts with /admin, it is the Web interface
$HTTP["url"] =~ "^/admin/" {
    # Create a response header for debugging using curl -I
    setenv.add-response-header = (
        "X-Pi-hole" => "The Pi-hole Web interface is working!",
        "X-Frame-Options" => "DENY"

Which is tricky, for it always return a 200/HTTP and doesn't send you anywhere on itself.

Have a go and tell us if it worked ! :slight_smile:

1 Like

So, I did that this morning. Deployed a traefik container in front of my pihole+dhcp-helper stack, and it works. Though without having to strip prefix. I'm not sure why, but redirection occurs nonetheless.

Just to clear any confusion, you'll find my stacks configs here : Pihole + dhcp-helper docker stack with traefik on side (http trafic only) · GitHub

Hope it helps !