Trusted Host setting for HTTP fails

Support intro

Adding a new host to Trusted_Hosts in config.php doesn’t seem to work.
I have a valid DNS entry for cloud.extradomain.tld pointing to the same server as cloud.originaldomain.tld

I run apache vhost with HTTP to HTTPS redirect for cloud.originaldomain.tld and this domain is still working as it has been doing for years now.

Adding http://cloud.extradomain.tld with a separate vhost file in Apache (without any SSL configuration) and adding cloud.extradomain.tld to the trusted_hosts keeps giving “access denied for untrusted domain” (Nextcloud warning page).

Strange!

Nextcloud version (eg, 20.0.6): 20.0.6
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apach 2.4
PHP version (eg, 7.4): php 7.2

The issue you are facing:

Can’t get new domain be trusted by Nextcloud.

Is this the first time you’ve seen this error? (Y/N): Y

Error file doesn’t show any hints, just that cloud.extradomein.tld is untrusted

config.php has line for the trusted domain : x => ‘cloud.extradomain.tld’,

Perhaps you can delete the line in config/config.php and add it with occ:

sudo -u www-data php occ config:system:set trusted_domains 2 --value=your.domain

Use the correct number e.g. 2.

Thanks for the hint. The result makes me puzzled even more. Deleting #2 from that array gave a new list (in the config.php file) with older values. Deleting all values using occ and starting all over with setting new values, also gave a list of older values. Very strange, very very strange.

user@hostname:~$ sudo -u www-data php occ config:system:delete trusted_domains 3
System config value trusted_domains => 3 deleted
user@hostname:~$ sudo cat /var/www/cloud/config/config.php | grep trusted -A 6
‘trusted_domains’ =>
array (
0 => ‘cloud.domain.tld’,
1 => ‘cloud.other.tld’,
2 => ‘cloud.old.tld’,
4 => ‘webserver.localdomain’,
),
user@hostname:~$ sudo -u www-data php occ config:system:delete trusted_domains 4
System config value trusted_domains => 4 deleted
user@hostname:~$ sudo cat /var/www/cloud/config/config.php | grep trusted -A 6
‘trusted_domains’ =>
array (
0 => ‘cloud.domain.tld’,
1 => ‘cloud.other.tld’,
2 => ‘cloud.old.tld’,
3 => ‘cloud.localdomain’,
),
user@hostname:~$ sudo -u www-data php occ config:system:delete trusted_domains 3
System config value trusted_domains => 3 deleted
user@hostname:~$ sudo cat /var/www/cloud/config/config.php | grep trusted -A 6
‘trusted_domains’ =>
array (
0 => ‘cloud.domain.tld’,
1 => ‘cloud.other.tld’,
2 => ‘cloud.old.nl’,
4 => ‘webserver.localdomain’,
),

Perhaps you use the wrong config/config.php .

Hum, Apache vhost points to /var/www/cloud