Docker: Trusted domain not working with docker compose

Created on 13 Dec 2018  Â·  7Comments  Â·  Source: nextcloud/docker

Hi,

i need help with adding a trusted domain. when i'm installing nextcloud everything works except that there is no trusted domain added to the config.php. Here is my docker compose and my db.env file (without passwords).

docker-compose:

version: '3'

services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=supersecurepassword
env_file:
- db.env

app:
image: nextcloud:apache
restart: always
ports:
- 80:80
- 443:443
volumes:
- nextcloud:/var/www/html
- /Volumes/Second/nextData:/data
environment:
- MYSQL_HOST=db
env_file:
- db.env
depends_on:
- db

volumes:
db:
nextcloud:

and my db.env

MYSQL_PASSWORD=superstrongpassword 
MYSQL_DATABASE=nextcloud 
MYSQL_USER=nextcloud NEXTCLOUD_DATA_DIR=/data
NEXTCLOUD_TRUSTED_DOMAINS=mydomain.tld

I see the following lines in the terminal with a fresh install:
Initializing nextcloud 14.0.3.0 ...
Initializing finished
New nextcloud instance

the install script (https://github.com/nextcloud/docker/blob/424364e2e10a9d6e1a31e6659e2149aac1f1c772/14.0/apache/entrypoint.sh) does not go to:

if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; 
  then echo "setting trusted domains…"

thx for any help!

Most helpful comment

I can confirm it worked after NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD are removed. Can we have a solution so it works when we use both NEXTCLOUD_ADMIN_USER and NEXTCLOUD_TRUSTED_DOMAINS?

All 7 comments

Hi guys, I exactly encounter the same strange behaviour with docker compose and nextcloud 15.0.4.
Was anyone able to solve this? I tried a lot and only once the trusted domains have been copied to the config.php... apparently I forgot this combination...

My docker compose looks like this:

version: '3'

services:
  nextcloud:
    container_name: nextcloud
    image: nextcloud:15
    depends_on:
      - nextcloud-redis
      - nextcloud-db
    restart: always
    ports:
      - "8030:80"
    volumes:
      - ${LOCAL_DOCKER_DIR}/html:/var/www/html
      - ${LOCAL_DOCKER_DIR}/data:/var/www/html/data
    environment:
      # The environment variable NEXTCLOUD_DATA_DIR 
      # takes the path of Nextcloud's data directory in the container 
      # (but you don't know all the folders your docker container can offer...
      # - NEXTCLOUD_DATA=/var/www/html/data
      # when using nextcloud_admin ifnormation than cli_url will be localhost.. 
      # otherwise you can control cli_host with url you use for last step of setup
      # - NEXTCLOUD_ADMIN_USER=nc_admin
      # - NEXTCLOUD_ADMIN_PASSWORD=${NC_ADMIN_PW}
      # - NEXTCLOUD_TABLE_PREFIX=oc_
      - NEXTCLOUD_TRUSTED_DOMAINS=cloud.mydomain.de playground.mydomain.de 10.0.6.229
      - POSTGRES_HOST=nextcloud-db
      - POSTGRES_DB=nc_db
      # ################
      # ################
      # here we need a postgres user that nextcloud uses to create a new limited user
      # --> https://docs.nextcloud.com/server/15/admin_manual/installation/installation_wizard.html#database-choice-label
      # "After you enter your root or administrator login for your database, the installer creates a special database user with privileges limited to the Nextcloud database. Then Nextcloud needs only the special Nextcloud database user, and drops the root dB login. This user is named for your Nextcloud admin user, with an oc_ prefix, and then given a random password. The Nextcloud database user and password are written into config.php"
      - POSTGRES_USER=nc_pg_root
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      # ################
      # ################
      - REDIS_HOST=nextcloud-redis
      - REDIS_HOST_PORT=6379

  nextcloud-cron:
    container_name: nextcloud-cron
    image: nextcloud:15
    depends_on:
      - nextcloud-redis
      - nextcloud-db
    restart: always
    volumes:
      - ${LOCAL_DOCKER_DIR}/html:/var/www/html
      - ${LOCAL_DOCKER_DIR}/data:/var/www/html/data
    entrypoint: /cron.sh

  nextcloud-db:
    image: postgres:11
    container_name: nextcloud-db
    restart: always
    environment:
     # we need a user for the nextcloud installer 
     # to create a limited user for nextcloud-db-access
     - POSTGRES_USER=nc_pg_root
     - POSTGRES_PASSWORD=${DB_PASSWORD}
     # POSTGRES_DB: nc_db
     - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
     - ${LOCAL_DOCKER_DIR}/db:/var/lib/postgresql/data
    command: ["-c", "shared_buffers=1GB", "-c", "max_connections=200", "-c", "effective_cache_size=3GB", "-c", "maintenance_work_mem=256MB", "-c", "checkpoint_completion_target=0.7", "-c", "wal_buffers=16MB", "-c", "default_statistics_target=100", "-c", "random_page_cost=1.1", "-c", "effective_io_concurrency=200", "-c", "work_mem=2621kB", "-c", "min_wal_size=1GB", "-c", "max_wal_size=2GB", "-c", "max_worker_processes=4", "-c", "max_parallel_workers_per_gather=2", "-c", "max_parallel_workers=4"]

  nextcloud-redis:
    container_name: nextcloud-redis
    image: redis:latest
    restart: always
    # sysctls:
    #   net.core.somaxconn: 1024
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - ${LOCAL_DOCKER_DIR}/redis:/data

networks:
  default:
    external:
      name: ${NETWORK}

and .env:

#
# Configuration for Nextcloud
#
# Persistent data folder
LOCAL_DOCKER_DIR=/srv/nextcloud
# Host
NC_HOSTNAME=cloud.mydomain.de playground.mydomain.de 10.0.6.229
# Postgres DB Password
DB_PASSWORD=Pwdsafe1234
# Nextcloud Admin Password
NC_ADMIN_PW=Pwdsafe1234
# Network name
NETWORK=webproxy

Hi bendschimmer,

I am no docker-expert but i tried again and this is what i found:

When you provide NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD as environment variables, then entrypoint.sh is fully used and also the trusted_domains part.

For me at least it was like this.. Without using the mentioned environmental variables it seems like instead of the whole entrypoint.sh the nextcloud installer itself is been used.. and in the normal nextcloud installer there is no trigger to put trusted_domains after install.

So i think for us the entrypoint ended after

if [ "$installed_version" = "0.0.0.0" ]; then
echo "New nextcloud instance"

Thx - i will give it a try!

I can confirm it worked after NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD are removed. Can we have a solution so it works when we use both NEXTCLOUD_ADMIN_USER and NEXTCLOUD_TRUSTED_DOMAINS?

hi, does someone know if this issue is solved?
I wonder if when I'm trying to give NEXTCLOUD_TRUSTED_DOMAINS multiple values, if i enter wrong syntax because, only the first value is written in config/config.php
I'm trying with this syntax (maybe I'm wrong) in my docker-compose.yml:
- NEXTCLOUD_TRUSTED_DOMAINS='localhost nextcloud.localhost 192.168.32.0 192.168.0.0' # nextcloud.mydomain.com

when i comment the three variables for admin credentials, and trusted domains, it works then i enter these information on web page

Any information would be great

Hi enima,

can you try this

  • NEXTCLOUD_TRUSTED_DOMAINS='localhost' 'nextcloud.localhost' '192.168.32.0' '192.168.0.0' # nextcloud.mydomain.com

Br

Hi enima,

can you try this

* NEXTCLOUD_TRUSTED_DOMAINS='localhost' 'nextcloud.localhost' '192.168.32.0' '192.168.0.0' # nextcloud.mydomain.com

Br

As soon as i did this, the database entries were screwed. Maby you need to " all of them?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pierreozoux picture pierreozoux  Â·  3Comments

DrMurx picture DrMurx  Â·  4Comments

SQGE picture SQGE  Â·  3Comments

mahnunchik picture mahnunchik  Â·  3Comments

raimund-schluessler picture raimund-schluessler  Â·  3Comments