Skip to content

Nextcloud says Access through untrusted domain

TroubleshootingDeployrr v6.0+CurrentTraefikDocker ComposeApp networking

You installed Nextcloud with Deployrr. When you open it, you get a Nextcloud page about an untrusted domain instead of the login page. This page shows how to add your address to Nextcloud’s list of allowed addresses.

You open https://nextcloud.YOUR_DOMAIN, or http://SERVER_IP:PORT. Nextcloud shows this:

Access through untrusted domain
Please contact your administrator. If you are an administrator, edit the "trusted_domains" setting in config/config.php

Nextcloud only answers on addresses in its trusted_domains setting. localhost always works. Behind Traefik, Nextcloud checks the address Traefik passes on to it, which is your subdomain.

Deployrr installs Nextcloud for you, with the admin user already set. There is no web setup page. The line NEXTCLOUD_TRUSTED_DOMAINS in nextcloud.yml only counts during that first install. After that, uncommenting it and recreating the container changes nothing. So your subdomain and your server IP may not be in the list.

On an installed Nextcloud, OVERWRITEHOST is the setting in nextcloud.yml that takes effect after a Recreate. Fix 2 below covers it.

If you use Nextcloud without Traefik, at http://SERVER_IP:PORT, read Local installs without Traefik too.

Section titled “Fix 1: add the addresses with occ (recommended)”

occ is Nextcloud’s command line tool. It changes the setting safely and takes effect at once. You don’t need a restart.

  1. See what Nextcloud trusts now:

    Terminal window
    sudo docker exec --user www-data nextcloud php occ config:system:get trusted_domains

    It prints one address per line. The first line is index 0. Count the lines to find the next free index. If you see localhost only, the next index is 1.

  2. Add your subdomain at the next free index. Replace nextcloud.example.com with your Nextcloud address, and 1 with your free index:

    Terminal window
    sudo docker exec --user www-data nextcloud php occ config:system:set trusted_domains 1 --value=nextcloud.example.com

    Leave out https:// and any port. Nextcloud ignores the port when it compares.

  3. Run the command from step 1 again. Your subdomain should now be in the list.

  4. Reload Nextcloud in your browser.

This option makes Nextcloud trust every address and build all its links with your subdomain. It turns off Nextcloud’s address check, so Fix 1 is the safer choice when you can use it. Use Fix 2 only if you reach Nextcloud through Traefik with your own domain.

  1. Open YOUR_DOCKER_FOLDER/compose/HOSTNAME/nextcloud.yml. See Docker folder layout for both placeholders.

  2. In the environment section, remove the # in front of OVERWRITEHOST:

    - OVERWRITEHOST=$NEXTCLOUD_SUBDOMAIN.$DOMAINNAME_1
  3. You can remove the # in front of NEXTCLOUD_TRUSTED_DOMAINS too. It does no harm, but it only matters on a fresh install.

  4. Save the file.

  5. Recreate Nextcloud. Go to Tools > Stack Manager > Recreate and pick nextcloud, not nextcloud-mariadb or nextcloud-redis. This needs a Basic, Plus or Pro license. See Stack Manager. If you set up the Deployrr bash aliases, you can run this instead:

    Terminal window
    dcrec nextcloud

    Without Stack Manager or the aliases, run this. Replace YOUR_DOCKER_FOLDER and HOSTNAME as in step 1:

    Terminal window
    sudo docker compose --profile all -f YOUR_DOCKER_FOLDER/docker-compose-HOSTNAME.yml up -d --force-recreate nextcloud

    Start or restart doesn’t read the changed file, so it is not enough. See Restart, Recreate or Reinstall an app after a change.

What this changes:

  • Nextcloud accepts any address, so the untrusted page goes away.
  • Nextcloud’s links and redirects point to your subdomain, even when you start from another address.
  • To undo it, put the # back and recreate Nextcloud. Then check with sudo docker exec --user www-data nextcloud php occ config:system:get overwritehost. If it still prints your subdomain, remove it with sudo docker exec --user www-data nextcloud php occ config:system:delete overwritehost.

You can install Nextcloud without Traefik and open it at http://SERVER_IP:PORT. The port is 8081 unless you picked another one. Two things get in the way:

  • Your server’s IP address is not in trusted_domains. Add it with Fix 1, with your IP as the value, for example --value=192.168.1.50. Don’t use Fix 2.
  • nextcloud.yml has the line - OVERWRITEPROTOCOL=https. It makes Nextcloud build its links with https, but the port only speaks plain http. After you log in, you can land on an https://SERVER_IP:PORT address that doesn’t load.

To switch Nextcloud to plain http:

  1. Open YOUR_DOCKER_FOLDER/compose/HOSTNAME/nextcloud.yml and put a # in front of the line:

    # - OVERWRITEPROTOCOL=https
  2. Save the file and recreate Nextcloud as in Fix 2, step 5.

  3. Check that the setting is gone:

    Terminal window
    sudo docker exec --user www-data nextcloud php occ config:system:get overwriteprotocol

    If it still prints https, remove it:

    Terminal window
    sudo docker exec --user www-data nextcloud php occ config:system:delete overwriteprotocol

If you add Traefik later, remove the # again and recreate Nextcloud.

If you use Nginx Proxy Manager instead of Traefik, the untrusted page has the same fix. Add the address you typed in NPM’s Domain Names with Fix 1. In the proxy host, use nextcloud as Forward Hostname / IP and 80 as Forward Port.

You also need to tell Nextcloud to trust NPM. The line TRUSTED_PROXIES=192.168.90.0/24 in nextcloud.yml covers Traefik’s network only. NPM and Nextcloud sit on the default Docker network, and Docker picks its addresses. Until you add that network, Nextcloud sees NPM’s address instead of each visitor’s. Its brute force protection can then slow down logins for everyone after a few failed logins.

  1. Find the name of the network Nextcloud is on:

    Terminal window
    sudo docker inspect nextcloud --format '{{range $name, $net := .NetworkSettings.Networks}}{{$name}} {{end}}'

    It prints your Docker folder’s name plus _default, for example docker_default when your Docker folder is /home/YOUR_USER/docker.

  2. Get that network’s address range. Replace docker_default with the name from step 1:

    Terminal window
    sudo docker network inspect docker_default --format '{{range .IPAM.Config}}{{.Subnet}} {{end}}'

    It prints a range such as 172.18.0.0/16.

  3. Open YOUR_DOCKER_FOLDER/compose/HOSTNAME/nextcloud.yml. Add the range to the TRUSTED_PROXIES line, after a space. Keep Traefik’s range:

    - TRUSTED_PROXIES=192.168.90.0/24 172.18.0.0/16

    Use a space between the ranges, not a comma.

  4. Save the file and recreate Nextcloud as in Fix 2, step 5.

  5. Check the setting:

    Terminal window
    sudo docker exec --user www-data nextcloud php occ config:system:get trusted_proxies

    It should print both ranges, one per line.

Set it in nextcloud.yml, not with occ config:system:set. The value in nextcloud.yml takes priority over config.php, so an occ change to trusted_proxies has no effect.

If the stack is ever taken down and started again, Docker can give the default network a new range. If Nextcloud stops showing visitors’ addresses, repeat steps 1 to 4. Repeat them after you reinstall Nextcloud too, because a reinstall copies a fresh nextcloud.yml.

  1. Open https://nextcloud.YOUR_DOMAIN, or http://SERVER_IP:PORT on a local install. You should see the Nextcloud login page.
  2. Log in with the admin user from your install. Deployrr showed it at the end of the install.
  3. Click around a few pages. The address bar should keep the address you opened.