Untrusted domain after adding domain

I can’t figure this out, I have looked at the forums and any solution that I find doesn’t work. I followed this guide: https://www.baeldung.com/linux/nextcloud-snap-installation. I installed it using snap, here is my /var/snap/nextcloud/current/nextcloud/config/config.php file

<?php $CONFIG = array ( 'apps_paths' => array ( 0 => array ( 'path' => '/snap/nextcloud/current/htdocs/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps', 'url' => '/extra-apps', 'writable' => true, ), ), 'supportedDatabases' => array ( 0 => 'mysql', ), 'memcache.locking' => '\\OC\\Memcache\\Redis', 'memcache.local' => '\\OC\\Memcache\\Redis', 'redis' => array ( 'host' => '/tmp/sockets/redis.sock', 'port' => 0, ), 'log_type' => 'file', 'logfile' => '/var/snap/nextcloud/current/logs/nextcloud.log', 'logfilemode' => 416, 'maintenance_window_start' => 1, 'passwordsalt' => 'TLocVgDIgSLTY3NIvCEZSeYQ/NqXeZ', 'secret' => 'SeG6zVveKx9BLbMk7Ko4Hls9XqVoWbWR17jClrauM82/K8vF', 'trusted_domains' => array ( 0 => 'localhost', 1 => array ( 'nextcloud.domain.com' => '', 'https://nextcloud.domain.com' => '', ), 2 => array ( 'https://nextcloud.domain.com' => '', ), 3 => array ( 'nextcloud.domain.com' => '', ), ), 'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data', 'dbtype' => 'mysql', 'version' => '30.0.4.1', 'overwrite.cli.url' => 'http://localhost', 'dbname' => 'nextcloud', 'dbhost' => 'localhost:/tmp/sockets/mysql.sock', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'nextcloud', 'dbpassword' => '4StZm09Zk9nzSmHHX-H7dL-SFRihbpX9nvRryDIztZvJoFEYNafDT3tI4igO_HmL', 'installed' => true, 'instanceid' => 'ocn9n1kascls', ); Whenever I try to access the instance, it gives me the accessed through untrusted domain. I have enabled https with lets encrypt so I do access it with https. I also tried on a previous vm to access it with just http on its ip address, then with its domain on http. I added the domains in a similar way earlier before. This time I used the command in the guide, previously I opened the file and added the domain.

see here Configure config.php · nextcloud-snap/nextcloud-snap Wiki · GitHub

and Hosts & FQDN configuration

you should be fine if you use the correct FQDN notation and leave out the protocol prefixes http:// or https:// in the domain name in that array.

the array should look something like this:

 'trusted_domains' =>
  array (
    0 => 'cloud.yourdomain.xyz',
    1 => 'cloud.yourotherdomain.yzx',
    2 => 'localhost',
    3 => 'nextcloud.local',
  )

A fully qualified domain name (a.k.a absolute domain name) is a complete address that specifies its exact location in the internet’s domain name system DNS and resolves a “human readable domain name” to an IP address. It includes the hostname and the domain name, which uniquely identify a specific server on the internet. This specifies all domain levels, including the top-level domain (TLD), in hostname.domain.tld format.

Oh my I didn’t realize how terrible I put it in, I was so tired last night.

Ok, so that is what I did before. I just changed it back to that structure.
I am running ubuntu 22.04, the snap version of nextcloud. So I am changing the config file under /var/snap/nextcloud/current/nextcloud/config/config.php
I needed to add a comma after the array, otherwise I get an internal server error.
However, what I had was what happens use this command: sudo nextcloud.occ config:system:set trusted_domains 1 --value= example.com

which results in this:
Screenshot from 2024-12-20 09-53-31

Ok, I changed it to what you said and it is working. I really wish I had my old config to see what I did wrong. this is like the 3rd or 4th time I’ve set up nextcloud so I was pretty confident that I knew how to enter in the trusted domains for the config file. I guess I’ll close this. Thank you!!!

see the wiki setting trusted domains

sudo nextcloud.occ config:system:set trusted_domains 0 --value=cloud.yourdomain.xyz

your trusted domain settings as per screenshot may work now, but they are not correct. you should read PHP configuration options

it should look like this:

'trusted_domains' =>
  array (
    0 => 'cloud.yourdomain.xyz',
    1 => 'cloud.yourotherdomain.yzx',
    2 => 'localhost',
    3 => 'nextcloud.local',
  )

remove the protocol from the domain names

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.