# Traefik redirect with external Pi-Hole

**URL:** <https://community.traefik.io/t/traefik-redirect-with-external-pi-hole/25122>\
**Category:** Traefik v3 (latest)\
**Tags:** docker, middleware\
**Created:** [November 11, 2024, 9:29pm UTC](https://community.traefik.io/t/traefik-redirect-with-external-pi-hole/25122 "2024-11-11T21:29:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![passta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/passta/32/9544_2.png) [@passta](https://community.traefik.io/u/passta)\
**Post date:** [November 11, 2024, 9:29pm UTC](https://community.traefik.io/t/traefik-redirect-with-external-pi-hole/25122/1 "2024-11-11T21:29:22Z")

</div>

I've got an external Pi-Hole v6 instance that I am having trouble geting to work properly with Traefik v3. Basically I am having the exact same issue as this post.

> [@External Pihole behind Traefik redirect /admin](https://community.traefik.io/t/external-pihole-behind-traefik-redirect-admin/17383):
>
> Hi all, i have pihole installed on a different machine, so pi hole do not run as a docker container next to Traefik. What i have done is, that i added pihole as an external router to my config.yml. If i access the URL via my browser, i can see the start page of pihole, but after fill in my admin credentials, the site will always redirect to /admin So, i navigate to [https://pihole.local.localdomain.com](https://pihole.local.localdomain.com) I can see the pihole admin page. But after i fill in my admin credentials, i will be …

I've tried the middleware and regex settings as described, but it loads the admin page with an error, if I disable the middleware settings, I get a 403 error, but then I can just click the admin link and its fine.

---

<div class="post-metadata">

**Author:** ![passta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/passta/32/9544_2.png) [@passta](https://community.traefik.io/u/passta)\
**Post date:** [November 12, 2024, 12:55am UTC](https://community.traefik.io/t/traefik-redirect-with-external-pi-hole/25122/2 "2024-11-12T00:55:38Z")

</div>

Figured this out. In case anyone has the same issue, this solved it for me.

http:  
routers:  
pihole:  
entryPoints:  
- websecure  
rule: "Host(`pihole.domain.com`)"  
service: pihole  
tls:  
certResolver: letsencrypt  
middlewares:  
- pihole-redirect

middlewares:  
pihole-redirect:  
redirectRegex:  
permanent: true  
regex: "^[https://pihole.domain.com/?$](https://pihole.domain.com/?$)"  
replacement: "[https://pihole.domain.com/admin](https://pihole.domain.com/admin)"

services:  
pihole:  
loadBalancer:  
passHostHeader: true  
servers:  
- url: "[https://pihole](https://pihole) IP"

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [November 15, 2024, 12:56am UTC](https://community.traefik.io/t/traefik-redirect-with-external-pi-hole/25122/3 "2024-11-15T00:56:03Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
