Skip to content

Commit

Permalink
Merge pull request #1271 from pi-hole/admin-page-redirect
Browse files Browse the repository at this point in the history
[Docker Only] Configure lighttpd to redirect http://VIRTUAL_HOST or http://FTLCONF_LOCAL_IPV4 to /admin
PromoFaux authored Jan 15, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 2c04346 + 4c240a4 commit 45d5fa7
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME 0

ENV FTLCONF_LOCAL_IPV4 0.0.0.0
ENV VIRTUAL_HOST ""
ENV FTL_CMD no-daemon
ENV DNSMASQ_USER pihole

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$HTTP["url"] == "/" {
$HTTP["host"] == env.VIRTUAL_HOST {
url.redirect = ("" => "/admin/")
}
$HTTP["host"] == env.FTLCONF_LOCAL_IPV4 {
url.redirect = ("" => "/admin/")
}
}
7 changes: 4 additions & 3 deletions src/s6/debian-root/usr/local/bin/bash_functions.sh
Original file line number Diff line number Diff line change
@@ -348,9 +348,10 @@ setup_lighttpd_bind() {
}

setup_web_php_env() {
if [ -z "$VIRTUAL_HOST" ] ; then
VIRTUAL_HOST="$FTLCONF_LOCAL_IPV4"
fi;
# if the environment variable VIRTUAL_HOST is not set, or is empty, then set it to the IP address of the container
if [ -z "${VIRTUAL_HOST}" ] || [ "${VIRTUAL_HOST}" == "" ]; then
VIRTUAL_HOST="${FTLCONF_LOCAL_IPV4}"
fi

for config_var in "VIRTUAL_HOST" "CORS_HOSTS" "PHP_ERROR_LOG" "PIHOLE_DOCKER_TAG" "TZ"; do
local beginning_of_line=" \"${config_var}\" => "

0 comments on commit 45d5fa7

Please sign in to comment.