EDIT/TLDR: The issue was with the “Trusted Proxies” being entered wrong in the docker-compose.yml file and even after correcting them in the config.php, the system did not recover. Removing that from the docker-compose file and adding them to the config.php file manually AND initiating the config from the external URL AND adding HTTPS protocol override did the trick, and it is now working as expected.
Even more simplified ==> Adding the overrideprotocol=https to the docker-compose environments and initiating the config for a fresh docker install via the external https://subdomain.domain.com URL made it work. No need for trusted proxies in my case.
-----=====-----=====-----=====-----
I have followed the installation documents for nextcloud in docker, and I have torn up pfsense and haproxy config already and ruled those out as a possible issues…
I am using a brand new Ubuntu 22.0 LTS server VM with docker + compose v2 installed.
Once the Nextcloud docker has been spun up I went through the initial setup.
Once complete I can reach the Nextcloud server via the local ip address just fine, and if I try to load the https://subdomain.mydomain.com address, it loads and displays the expected “Untrusted domain…” error message.
My problem is, when I change the config.php and add “subdomain.mydomain.com” to the trusted domain array, and restart the docker, the site is reachable via the internal ip address, but when trying to load the site via the external domain, it errors out with " 504 Gateway Time-out" error message.
The only change that has happened is that I added the domain as trusted.
My config:
<?php
$CONFIG = array (
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' =>
array (
0 =>
array (
'path' => '/var/www/html/apps',
'url' => '/apps',
'writable' => false,
),
1 =>
array (
'path' => '/var/www/html/custom_apps',
'url' => '/custom_apps',
'writable' => true,
),
),
'trusted_proxies' =>
array (
0 => '192.168.11.1,10.0.0.0/8,127.0.0.1/8',
),
'upgrade.disable-web' => true,
'instanceid' => 'XXxxXXXxxXXXxxx',
'passwordsalt' => 'XXxxXXXxxXXXxxx',
'secret' => 'XXxxXXXxxXXXxxx',
'trusted_domains' =>
array (
0 => '192.168.11.10',
1 => 'subdomain.mydomain.com',
),
'datadirectory' => '/var/www/html/data',
'dbtype' => 'mysql',
'version' => '28.0.1.1',
'overwrite.cli.url' => 'http://192.168.11.10',
'dbname' => 'nextcloud',
'dbhost' => 'db',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => 'XXxxXXXxxXXXxxx',
'installed' => true,
);
Docker-compose.yml
version: '2'
volumes:
nextcloud:
db:
services:
db:
image: mariadb:10.6
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- /home/dragon/docker/Nextcloud/db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=XXxxXXxxXX
- MYSQL_PASSWORD=XXxxXXxxXX
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
image: nextcloud
restart: always
ports:
- 80:80
- 443:443
links:
- db
volumes:
- /mnt/Storage/Nextcloud:/var/www/html
environment:
- NEXTCLOUD_TRUSTED_DOMAINS=subdomain.mydomain.com,localhost,192.168.11.10:8080
- TRUSTED_PROXIES=192.168.11.1,10.0.0.0/8,127.0.0.1/8
- PHP_MEMORY_LIMIT=4096M
- PHP_UPLOAD_LIMIT=4096M
- MYSQL_PASSWORD=XXxxXXxxXX
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=db
If I remove the domain from the trusted domain, the site loads, with the “Untrusted domain…” error. but it loads ok
I have also tried:
- add the trusted proxies as an array in config.php
- set ‘overwrite.cli.url’ => ‘http://192.168.11.10’,
- set ‘overwritehost’ => ‘192.168.11.10’
- added 127.0.0.1/8 and 10.0.0.0/8 tot the trusted domains indiviually in an array
They all produced the same error…
Edit:
Further to the above I did a fresh VM install, updated everything, and it is still the same.
If I do not have the mydomain listed in the Tusted domains, then the site loads via the mydomain, has a valid, correct certificate, but when I add the mydomain to the “trusted domains” list, the page load errors out with 504 Gateway Time-out.
This to me shows that it’s either the docker image, or something in Nextcloud is off… Please point me to something I am missing here, as I can’t get past this…
Thank you