From 1ee74f1d42f69ad4831b6b7ebaa5dabe24332d86 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 17 Apr 2024 18:01:12 +0200 Subject: [PATCH 1/2] trust IP of docker network gateway Signed-off-by: Zoey --- Containers/nextcloud/entrypoint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 44ed9acd..0fc9ccb2 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -537,8 +537,10 @@ fi chmod 775 -R /var/www/html/custom_apps/notify_push/bin/ php /var/www/html/occ config:system:set trusted_proxies 0 --value="127.0.0.1" php /var/www/html/occ config:system:set trusted_proxies 1 --value="::1" +# IP of docker network gateway +php /var/www/html/occ config:system:set trusted_proxies 2 --value="$(ip r | grep default | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.1")" if [ -n "$ADDITIONAL_TRUSTED_PROXY" ]; then - php /var/www/html/occ config:system:set trusted_proxies 2 --value="$ADDITIONAL_TRUSTED_PROXY" + php /var/www/html/occ config:system:set trusted_proxies 3 --value="$ADDITIONAL_TRUSTED_PROXY" fi if [ -n "$ADDITIONAL_TRUSTED_DOMAIN" ]; then php /var/www/html/occ config:system:set trusted_domains 2 --value="$ADDITIONAL_TRUSTED_DOMAIN" From 03792a5661f74766e8a2852e1b6a8c5fb603a640 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Thu, 25 Apr 2024 16:51:33 +0200 Subject: [PATCH 2/2] use the same logic like in apache Signed-off-by: Simon L --- Containers/nextcloud/entrypoint.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 0fc9ccb2..28fcf02f 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -537,11 +537,17 @@ fi chmod 775 -R /var/www/html/custom_apps/notify_push/bin/ php /var/www/html/occ config:system:set trusted_proxies 0 --value="127.0.0.1" php /var/www/html/occ config:system:set trusted_proxies 1 --value="::1" -# IP of docker network gateway -php /var/www/html/occ config:system:set trusted_proxies 2 --value="$(ip r | grep default | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.1")" if [ -n "$ADDITIONAL_TRUSTED_PROXY" ]; then - php /var/www/html/occ config:system:set trusted_proxies 3 --value="$ADDITIONAL_TRUSTED_PROXY" + php /var/www/html/occ config:system:set trusted_proxies 2 --value="$ADDITIONAL_TRUSTED_PROXY" fi + +# Get ipv4-address of Nextcloud +IPv4_ADDRESS="$(dig nextcloud-aio-nextcloud A +short +search | head -1)" +# Bring it in CIDR notation +# shellcheck disable=SC2001 +IPv4_ADDRESS="$(echo "$IPv4_ADDRESS" | sed 's|[0-9]\+$|1/32|')" +php /var/www/html/occ config:system:set trusted_proxies 10 --value="$IPv4_ADDRESS" + if [ -n "$ADDITIONAL_TRUSTED_DOMAIN" ]; then php /var/www/html/occ config:system:set trusted_domains 2 --value="$ADDITIONAL_TRUSTED_DOMAIN" fi