diff --git a/Containers/apache/Dockerfile b/Containers/apache/Dockerfile index ae6f5278..a787593e 100644 --- a/Containers/apache/Dockerfile +++ b/Containers/apache/Dockerfile @@ -30,6 +30,7 @@ RUN set -ex; \ tzdata \ ca-certificates \ openssl \ + bind-tools \ netcat-openbsd; \ \ sed -i \ diff --git a/Containers/apache/start.sh b/Containers/apache/start.sh index 5ebc9ee0..040851bc 100644 --- a/Containers/apache/start.sh +++ b/Containers/apache/start.sh @@ -17,6 +17,11 @@ while ! nc -z "$NEXTCLOUD_HOST" 9000; do sleep 5 done +# Get ipv4-address of Apache +IPv4_ADDRESS="$(dig nextcloud-aio-apache A +short | head -1)" +# Bring it in CIDR notation +IPv4_ADDRESS="$(echo "$IPv4_ADDRESS" | sed 's|[0-9]\+$|1/32|')" + if [ -z "$APACHE_PORT" ]; then export APACHE_PORT="443" fi @@ -41,7 +46,7 @@ echo "$CADDYFILE" > /tmp/Caddyfile if [ "$APACHE_PORT" != '443' ]; then CADDYFILE="$(sed 's|# trusted_proxies placeholder|trusted_proxies static private_ranges|' /tmp/Caddyfile)" else - CADDYFILE="$(sed 's|trusted_proxies.*private_ranges|# trusted_proxies placeholder|' /tmp/Caddyfile)" + CADDYFILE="$(sed "s|# trusted_proxies placeholder|trusted_proxies static $IPv4_ADDRESS|" /tmp/Caddyfile)" fi echo "$CADDYFILE" > /tmp/Caddyfile