Nextcloud (in Docker) not accepting trusted domains

I’m having a problem adding a new domain to “trusted domains” in the config.php

I’ve added 192.168.178.5 and it works just fine. But when i try to add “cloud” or “cloud.fritz.box” and i want to access the web interface with “cloud/” “cloud.fritz.box/” it says:

Access via an untrusted domain
Please contact your administrator. If you are an administrator, edit the trusted_domains setting in config / config.php. See example in config / config.sample.php.

Translated from german to english. Accessing with 192.168.178.5/ works just fine.

1 Like

Are you manually editing the file or using occ to add it?

@KarlF12

Are you manually editing the file or using occ to add it?

I’ve tried editing it manually with " root@Butlr:/var/lib/docker/volumes/nextcloud-data/_data/config# nano config.php " but that doesnt seem to work.

How do you use the occ/what is occ? I’m still fairly new with docker/nextcloud.

I’ve tried doing " docker exec -u www-data -it Nextcloud /bin/bash " but this doesnt seem to have nano installed and i dont have “sudo” for some reason.

Thanks !

never do this.

also never ever.

what you want to do:

first setup your docker container in this way that config.php is “outside” the container in a save place on your host. you do this by defining a volume -v <host-path>:/var/www/html. that makes your changes to the nextcloud config persistent to docker image updates. also apps and themes are persistent to updates of the docker image. (btw: it’s important to understand the difference between images and container. google and youtube will help you. :wink: )

now you could edit <host-path>/config/config.php.

occ is the comand line tool to administer nextcloud. in the docker world you run sudo docker exec --user www-data <nextcloud-docker-id> php occ <occ:command options>

e.g.: docker exec --user www-data nextcloud php occ overwrite.cli.url --value=https://cloud.fritz.box

https://docs.nextcloud.com/server/17/admin_manual/configuration_server/occ_command.html

some examples. note: you have to put docker exec --user www-data nextcloud php occ in front of each line. remove '- " … " ’ around each line. {{ … }} are variables in this notation. i think you guess the real values to put in.

note that the value of “trusted domains” in the config.php is an array. you are sure you didn’t made a typo?

Thanks alot @Reiner_Nippes

I’ve now used

docker exec --user www-data Nextcloud php occ config:system:get trusted_domains

docker exec --user www-data Nextcloud php occ config:system:set trusted_domains 2 --value=cloud

And it does work. I’ll look into releasing files from a container onto the host for future use.

2 Likes

You can also find instructions for doing that part in the official image documentation under Persistent Data.

https://hub.docker.com/_/nextcloud

1 Like

You can find the command line to add new domain and more here :

@Reiner_Nippes, hey so I ran command as you said, I am getting this error. I am running this in docker.

Command “overwrite.cli.url” is not defined.

Any suggestion? Thanks.

@nandurx the command is php the parameter are occ as the php programm to execute and config:system:set trusted_domains 2 --value=cloud as what you want occ to do.

to make this work you have to be in the folder where occ is located (/var/www/html) which is the home directory of the user www-data. that why

docker exec --user www-data Nextcloud php occ config:system:set trusted_domains 2 --value=cloud

works out of the box when you run it on your hosts cli.

in case you run the correct command and got this error message just try:

docker exec --user www-data Nextcloud php occ
docker exec --user www-data nextcloud php occ status
docker exec --user www-data nextcloud php occ --help

@Reiner_Nippes: Hey, so I have figured it out. I just made directory outside on sharedfolder and it worked. (I read somewhere on this forum)

I have another question!!!

Does NGNIX proxy manager and nextcloud has any correlation or with mariaDB? Because I deleted nextcloud database in order to do fresh install as I had to change directory as someone recommended to get access through trusted domain. my NGNIX docker stopped working. I thought container doesn’t have effect with other container.

It happened twice as I tried installing nextcloud twice.

I was using command: DROP DATABASE database name; inside mariaDB.

Any clues?

you can link container. that is to say docker waits till mariadb and redis container are started before starting nextcloud and after that starting nginx and nginx proxy.

also if you stop/update mariadb container nextcloud container could be restarted to reconnect to the database.

so what do you mean by this? of course you can’t reach nextcloud web page anymore. the nextcloud container might chance to a state where it is restarted till it can reconnect to the database.

but the two nginx container should not be affected.

I mean using my local ips. As soon as delete database for Nextcloud, ngnix stop working. Really odd.

So, just a question: In order for anybody to get nextcloud working, you have to jump through all these hoops and edit these config files? I’m an expert in the command line, but how do other people manage this? This is very basic, because you can’t use nextcloud with just localhost on the server, why isn’t this configurable in the web interface? I think this would stop quite a few less tech savy people from using Nextcloud. Or do I miss some information?

No, you don’t have to. Although in practice you probably can’t avoid using the OCC command or changing something in config.php completly.

In this particular case, however, it would not be necessary to change anything, if you would have a proper DNS setup in your local network. Adding more trusted domains for local IP addresses or internal domain names is only necessary if you have to workaround the lack of internal DNS resolution or NAT reflection. The clean solution here would be to make sure that DNS works properly on the internal network instead of adding the local IP of the server to the trusted domains, which then leads to further problems if you want to share links with external users or use Nextxcloud on devices that sometimes are on the internal network and sometimes outside, such as mobile phones.

I have similar issue with trusted domains. This is how i have my volumes. I have edited my config.php and there is no way… Can you help me?

Host/volume Path in container
/home/pi/Docker/Nextcloud/config /congif
/mnt/HDD/Nextcloud /data
fa8ee39e722f40205693f009d7e7ef0fc64dd2c9f2e118f5d5a64dd2919ee96a /config