Monday, February 3, 2020

Nextcloud trustedhosts error

When we try to access the nextcloud URL with IPAddress, you might get error as not a trusted host error.

So, you can add the IP address to nexcloud config.php file.

It is located in: /snap/nextcloud/18204/htdocs/config/config.php or /var/www/nextcloud/config/config.php

Or else, you can run below commands.

To see list of trusted hosts:

sudo nextcloud.occ config:system:get trusted_domains

To add to trusted hosts, either IP or domain address.

 sudo nextcloud.occ config:system:set trusted_domains X --value=10.1.85.219


Ref: 
https://docs.nextcloud.com/server/16/admin_manual/installation/installation_wizard.html#trusted-domains

https://help.nextcloud.com/t/access-through-untrusted-domain/68368

https://help.nextcloud.com/t/how-do-i-edit-the-config-php-file-on-a-nextcloud-box/12217


If you have installed using the zip file,generally on a windows server with WSL ubuntu.
The config file will be available at 
"C:\ubuntu\rootfs\var\www\html\nextcloud\config\config.php"

You can edit the file and add entry as below.

  array (
    0 => 'localhost',
    1 => 'server1.example.com',
    2 => 'X: 104.208.245.105',
    3 => '[fe80::1:50]',
    4 => '104.208.245.105/nextcloud',
    5 => 'http://104.208.245.105/nextcloud',
    6 => '10.0.0.4',
    'X' => '104.208.245.105',
  ), 

Or, you can add entry using command line.
Here, the command line should run as a php file.

 sudo -u '#33' php /var/www/html/nextcloud/occ config:system:get trusted_domains

sudo -u '#33' php /var/www/html/nextcloud/occ config:system:set trusted_domains X --value=104.208.245.105

Above #33 is the profile having permission, which we will get from error description when we run without -u option.

No comments:

Post a Comment