Instead of including a static config file for redirecting it - dynamically create this file on container start.
This gets rid of what was probably a hack to have the VIRTUAL_HOST declared as an empty string in the Dockerfile (lighttpd would not start if env.VIRTUAL_HOST was not set Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
ad6b8a6f0e
commit
d7ff34fd74
|
@ -31,7 +31,6 @@ 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
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
$HTTP["url"] == "/" {
|
||||
$HTTP["host"] == env.VIRTUAL_HOST {
|
||||
url.redirect = ("" => "/admin/")
|
||||
}
|
||||
$HTTP["host"] == env.FTLCONF_LOCAL_IPV4 {
|
||||
url.redirect = ("" => "/admin/")
|
||||
}
|
||||
}
|
|
@ -117,8 +117,6 @@ ensure_basic_configuration() {
|
|||
if [ ! -f /etc/dnsmasq.d/01-pihole.conf ] ; then
|
||||
cp /etc/.pihole/advanced/01-pihole.conf /etc/dnsmasq.d/
|
||||
fi;
|
||||
|
||||
# setup_or_skip_gravity
|
||||
}
|
||||
|
||||
validate_env() {
|
||||
|
@ -364,9 +362,7 @@ setup_web_php_env() {
|
|||
local config_file
|
||||
config_file="/etc/lighttpd/conf-available/15-pihole-admin.conf"
|
||||
# if the environment variable VIRTUAL_HOST is not set, or is empty, then set it to the hostname of the container
|
||||
if [ -z "${VIRTUAL_HOST}" ] || [ "${VIRTUAL_HOST}" == "" ]; then
|
||||
VIRTUAL_HOST="${HOSTNAME}"
|
||||
fi
|
||||
VIRTUAL_HOST="${VIRTUAL_HOST:-$HOSTNAME}"
|
||||
|
||||
for config_var in "VIRTUAL_HOST" "CORS_HOSTS" "PHP_ERROR_LOG" "PIHOLE_DOCKER_TAG" "TZ"; do
|
||||
local beginning_of_line=" \"${config_var}\" => "
|
||||
|
@ -381,6 +377,19 @@ setup_web_php_env() {
|
|||
|
||||
echo " [i] Added ENV to php:"
|
||||
grep -E '(VIRTUAL_HOST|CORS_HOSTS|PHP_ERROR_LOG|PIHOLE_DOCKER_TAG|TZ)' "$config_file"
|
||||
|
||||
# Create an additional file in the lighttpd config directory to redirect the root to the admin page
|
||||
# if the host matches either VIRTUAL_HOST (Or HOSTNAME if it is not set) or FTLCONF_LOCAL_IPV4
|
||||
cat <<END > /etc/lighttpd/conf-enabled/15-pihole-admin-redirect-docker.conf
|
||||
\$HTTP["url"] == "/" {
|
||||
\$HTTP["host"] == "${VIRTUAL_HOST}" {
|
||||
url.redirect = ("" => "/admin/")
|
||||
}
|
||||
\$HTTP["host"] == "${FTLCONF_LOCAL_IPV4}" {
|
||||
url.redirect = ("" => "/admin/")
|
||||
}
|
||||
}
|
||||
END
|
||||
}
|
||||
|
||||
setup_web_port() {
|
||||
|
|
Loading…
Reference in New Issue