Pi-hole admin page redirect failure
Pi-hole admin page redirect failure
I run two Pi-hole instances for redundancy, on two different hardware devices.
I ran into a small, but annoying, issue when trying to access the web admin page.
When accessing the admin web page, Pi-hole should redirect / to /admin, but it wasn't on just one of my Pi-hole instances.
When accessing the admin page of my Pi-hole instance without adding the /admin, I would get a HTTP response code of 403 Forbidden.
Once I added the /admin to the URL, the admin page came up fine.
As both Pi-holes are running the same version of code, I figured it was a config issue and not a software bug.
Minor issue, but annoyed me that one Pi-hole had this issue, the other didn't.
After doing some digging, found out that /etc/lighttpd/conf-enabled/15-pihole-admin-redirect-docker.conf file has a $HTTP["host"] setting that tells Pi-hole when to add the /admin to a request.
On the broken Pi-hole, this was set to the Docker container ID df1846696cbc and not the IP 192.168.1.5.
/etc/lighttpd/conf-enabled# cat 15-pihole-admin-redirect-docker.conf
$HTTP["url"] == "/" {
$HTTP["host"] == "df1846696cbc" {
url.redirect = ("" => "/admin/")
}
$HTTP["host"] == "0.0.0.0" {
url.redirect = ("" => "/admin/")
}
}
A quick fix would be to replace df1846696cbc with 192.168.1.5, but a long term and permanent fix was to add an environment variable VIRTUAL_HOST to the Docker compose file and set that to the IP of the Pi-hole container (192.168.1.5)
My new (partial) Docker compose yaml file:
version: "3"
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- 53:53/tcp
- 53/udp
- 80/tcp
- 443/tcp
environment:
VIRTUAL_HOST: 192.168.1.5
References
Pi-hole.net - Redirect / to /admin https://discourse.pi-hole.net/t/redirect-to-admin/44103/6