From 1c8e46708feae11304db3c5059611efd1ad74045 Mon Sep 17 00:00:00 2001 From: Simon L Date: Wed, 24 Jan 2024 15:25:43 +0100 Subject: [PATCH] allow to add nextcloud-aio-caddy ip-address to trusted proxies automatically Signed-off-by: Simon L --- manual-install/update-yaml.sh | 1 + php/containers.json | 1 + php/src/Docker/DockerActionManager.php | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/manual-install/update-yaml.sh b/manual-install/update-yaml.sh index da40f406..2c67aafc 100644 --- a/manual-install/update-yaml.sh +++ b/manual-install/update-yaml.sh @@ -40,6 +40,7 @@ sed -i 's|- ip_binding: |- |' containers.yml sed -i '/AIO_TOKEN/d' containers.yml sed -i '/AIO_URL/d' containers.yml sed -i '/DOCKER_SOCKET_PROXY_ENABLED/d' containers.yml +sed -i '/ADDITIONAL_TRUSTED_PROXY/d' containers.yml TCP="$(grep -oP '[%A-Z0-9_]+/tcp' containers.yml | sort -u)" mapfile -t TCP <<< "$TCP" diff --git a/php/containers.json b/php/containers.json index b62c4236..2ee9a131 100644 --- a/php/containers.json +++ b/php/containers.json @@ -213,6 +213,7 @@ "REMOVE_DISABLED_APPS=%REMOVE_DISABLED_APPS%", "APACHE_PORT=%APACHE_PORT%", "APACHE_IP_BINDING=%APACHE_IP_BINDING%", + "ADDITIONAL_TRUSTED_PROXY=%CADDY_IP_ADDRESS%", "THIS_IS_AIO=true" ], "stop_grace_period": 600, diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index c0772013..50b9c977 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -406,6 +406,13 @@ class DockerActionManager // Allow to get local ip-address of database container which allows to talk to it even in host mode (the container that requires this needs to be started first then) } elseif ($out[1] === 'AIO_DATABASE_HOST') { $replacements[1] = gethostbyname('nextcloud-aio-database'); + // Allow to get local ip-address of caddy container and add it to trusted proxies automatically + } elseif ($out[1] === 'CADDY_IP_ADDRESS') { + $replacements[1] = ''; + $communityContainers = $this->configurationManager->GetEnabledCommunityContainers(); + if (in_array('caddy', $communityContainers, true)) { + $replacements[1] = gethostbyname('nextcloud-aio-caddy'); + } } else { $secret = $this->configurationManager->GetSecret($out[1]); if ($secret === "") {