Skip to content

Commit

Permalink
Merge pull request #4912 from nextcloud/no-listen
Browse files Browse the repository at this point in the history
Implement internal mode
  • Loading branch information
szaimen committed Jul 11, 2024
2 parents 6463df7 + c69aa56 commit d304c79
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Containers/mastercontainer/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ It is set to '$APACHE_PORT'."
fi
fi
if [ -n "$APACHE_IP_BINDING" ]; then
if ! echo "$APACHE_IP_BINDING" | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$\|^[0-9a-f:]\+$'; then
if ! echo "$APACHE_IP_BINDING" | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$\|^[0-9a-f:]\+$\|^@INTERNAL$'; then
print_red "You provided an ip-address for the apache container's ip-binding but it was not a valid ip-address.
It is set to '$APACHE_IP_BINDING'."
exit 1
Expand Down
2 changes: 1 addition & 1 deletion community-containers/caddy/caddy.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
],
"aio_variables": [
"apache_ip_binding=127.0.0.1",
"apache_ip_binding=@INTERNAL",
"apache_port=11000"
],
"nextcloud_exec_commands": [
Expand Down
1 change: 0 additions & 1 deletion php/containers.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
"DOCKER_SOCKET_PROXY_ENABLED=%DOCKER_SOCKET_PROXY_ENABLED%",
"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",
"IMAGINARY_SECRET=%IMAGINARY_SECRET%"
Expand Down
12 changes: 7 additions & 5 deletions php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function GetContainerStartingState(Container $container) : IContainerStat
} elseif($internalPort === '%TALK_PORT%') {
$internalPort = $this->configurationManager->GetTalkPort();
}

if ($internalPort !== "" && $internalPort !== 'host') {
$connection = @fsockopen($containerName, (int)$internalPort, $errno, $errstr, 0.2);
if ($connection) {
Expand Down Expand Up @@ -295,8 +295,6 @@ public function CreateContainer(Container $container) : void {
$replacements[1] = $this->configurationManager->GetSelectedRestoreTime();
} elseif ($out[1] === 'APACHE_PORT') {
$replacements[1] = $this->configurationManager->GetApachePort();
} elseif ($out[1] === 'APACHE_IP_BINDING') {
$replacements[1] = $this->configurationManager->GetApacheIPBinding();
} elseif ($out[1] === 'TALK_PORT') {
$replacements[1] = $this->configurationManager->GetTalkPort();
} elseif ($out[1] === 'NEXTCLOUD_MOUNT') {
Expand Down Expand Up @@ -438,7 +436,7 @@ public function CreateContainer(Container $container) : void {
$requestBody['HostConfig']['RestartPolicy']['Name'] = $container->GetRestartPolicy();

$requestBody['HostConfig']['ReadonlyRootfs'] = $container->GetReadOnlySetting();

$exposedPorts = [];
if ($container->GetInternalPort() !== 'host') {
foreach($container->GetPorts()->GetPorts() as $value) {
Expand Down Expand Up @@ -478,6 +476,10 @@ public function CreateContainer(Container $container) : void {
$ipBinding = $value->ipBinding;
if ($ipBinding === '%APACHE_IP_BINDING%') {
$ipBinding = $this->configurationManager->GetApacheIPBinding();
// Do not expose if AIO is in internal network mode
if ($ipBinding === '@INTERNAL') {
continue;
}
}
$portWithProtocol = $port . '/' . $protocol;
$requestBody['HostConfig']['PortBindings'][$portWithProtocol] = [
Expand Down Expand Up @@ -708,7 +710,7 @@ private function GetRepoDigestsOfContainer(string $containerName) : ?array {
if (!isset($imageOutput['RepoDigests'])) {
error_log('RepoDigests is not set of container ' . $containerName);
return null;
}
}

if (!is_array($imageOutput['RepoDigests'])) {
error_log('RepoDigests of ' . $containerName . ' is not an array which is not allowed!');
Expand Down

0 comments on commit d304c79

Please sign in to comment.