From f9198b4ab2b62a023432139b63a5f3e9772e5f3a Mon Sep 17 00:00:00 2001 From: Keith Wansbrough Date: Tue, 30 Dec 2025 18:32:40 +0000 Subject: [PATCH] Add COLLABORA_EXTRA_HOSTS option Signed-off-by: Keith Wansbrough --- compose.yaml | 1 + php/src/Data/ConfigurationManager.php | 8 ++++++++ php/src/Docker/DockerActionManager.php | 4 ++++ readme.md | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/compose.yaml b/compose.yaml index c18d92d3..e29e630c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -22,6 +22,7 @@ services: # APACHE_ADDITIONAL_NETWORK: frontend_net # (Optional) Connect the apache container to an additional docker network. Needed when behind a web server or reverse proxy (like Apache, Nginx, Caddy, Cloudflare Tunnel and else) running in a different docker network on same server. See https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md # BORG_RETENTION_POLICY: --keep-within=7d --keep-weekly=4 --keep-monthly=6 # Allows to adjust borgs retention policy. See https://github.com/nextcloud/all-in-one#how-to-adjust-borgs-retention-policy # COLLABORA_SECCOMP_DISABLED: false # Setting this to true allows to disable Collabora's Seccomp feature. See https://github.com/nextcloud/all-in-one#how-to-disable-collaboras-seccomp-feature + # COLLABORA_EXTRA_HOSTS: "foo.example.org=2001:db8::1 bar.example.org=127.0.0.1" # space-separated list of extra /etc/hosts entries for Collabora container # DOCKER_API_VERSION: 1.44 # You can adjust the internally used docker api version with this variable. ⚠️⚠️⚠️ Warning: please note that only the default api version (unset this variable) is supported and tested by the maintainers of Nextcloud AIO. So use this on your own risk and things might break without warning. See https://github.com/nextcloud/all-in-one#how-to-adjust-the-internally-used-docker-api-version # FULLTEXTSEARCH_JAVA_OPTIONS: "-Xms1024M -Xmx1024M" # Allows to adjust the fulltextsearch java options. See https://github.com/nextcloud/all-in-one#how-to-adjust-the-fulltextsearch-java-options # NEXTCLOUD_DATADIR: /mnt/ncdata # Allows to set the host directory for Nextcloud's datadir. ⚠️⚠️⚠️ Warning: do not set or adjust this value after the initial Nextcloud installation is done! See https://github.com/nextcloud/all-in-one#how-to-change-the-default-location-of-nextclouds-datadir diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 320bc477..7df6dfec 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -763,6 +763,14 @@ class ConfigurationManager return trim($this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue)); } + public function GetCollaboraExtraHosts() : string { + $envVariableName = 'COLLABORA_EXTRA_HOSTS'; + $configName = 'collabora_extra_hosts'; + $defaultValue = ''; + $value = trim($this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue)); + return preg_split('/ +/', $value, -1, PREG_SPLIT_NO_EMPTY); + } + public function GetCollaboraSeccompPolicy() : string { $defaultString = '--o:security.seccomp='; if (!$this->isSeccompDisabled()) { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 9e8a8ff2..5f388cc2 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -425,6 +425,10 @@ readonly class DockerActionManager { if ($this->configurationManager->GetAdditionalCollaboraOptions() !== '') { $requestBody['Cmd'] = [$this->configurationManager->GetAdditionalCollaboraOptions()]; } + + if (count($this->configurationManager->GetCollaboraExtraHosts()) > 0) { + $requestBody['HostConfig']['ExtraHosts'] = $this->configurationManager->GetCollaboraExtraHosts(); + } } if (count($mounts) > 0) { diff --git a/readme.md b/readme.md index fc46b3fb..b4477df8 100644 --- a/readme.md +++ b/readme.md @@ -565,6 +565,10 @@ The Collabora container enables Seccomp by default, which is a security feature ### How to adjust the Fulltextsearch Java options? The Fulltextsearch Java options are by default set to `-Xms512M -Xmx512M` which might not be enough on some systems. You can adjust this by adding e.g. `--env FULLTEXTSEARCH_JAVA_OPTIONS="-Xms1024M -Xmx1024M"` to the initial docker run command. If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used. +### How to add additional hosts to Collabora's /etc/hosts? +You can override DNS for specific hosts within the Collabora container by adding e.g. `--env COLLABORA_EXTRA_HOSTS="foo.example.org=2001:db8::1 bar.example.org=127.0.0.1"` to the initial docker run command. If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used. + + ## Guides ### How to run AIO on macOS?