fix: sets trusted_domains correctly #118

Open
stevensting wants to merge 5 commits from trusted-domains into main
Owner

fixes the issue, that EXTRA_DOMAINS is not taken into consideration by nextcloud as trusted domain, and therefore does not work.

fixes the issue, that EXTRA_DOMAINS is not taken into consideration by nextcloud as trusted domain, and therefore does not work.
stevensting added 2 commits 2026-08-25 13:07:41 +00:00
stevensting requested review from dannygroenewegen 2026-08-25 13:18:53 +00:00
stevensting requested review from ineiti 2026-08-25 13:19:00 +00:00
dannygroenewegen requested changes 2026-08-26 10:39:13 +00:00
Dismissed
.env.sample Outdated
@@ -6,6 +6,8 @@ ENABLE_BACKUPS=true
DOMAIN=nextcloud.example.com
## Domain aliases
#EXTRA_DOMAINS=', `www.nextcloud.example.com`'
# same list as above but space separated
Owner

Maybe make the comments a bit more elaborate on what they both do?

Update the EXTRA_DOMAINS comment to #Additional domains for Traefik to listen on. Comma-separated, backtick-quoted, e.g. ', `www.nextcloud.example.com`'

And the comment for EXTRA_DOMAINS_TRUSTED:

# Same domains as above, but for Nextcloud to trust, space separated: "www.nextcloud.example.com alt.example.com"
# Only applied on first install. For existing instances run: occ config:system:set trusted_domains <idx> --value=<domain>
Maybe make the comments a bit more elaborate on what they both do? Update the EXTRA_DOMAINS comment to ```#Additional domains for Traefik to listen on. Comma-separated, backtick-quoted, e.g. ', `www.nextcloud.example.com`'``` And the comment for EXTRA_DOMAINS_TRUSTED: ``` # Same domains as above, but for Nextcloud to trust, space separated: "www.nextcloud.example.com alt.example.com" # Only applied on first install. For existing instances run: occ config:system:set trusted_domains <idx> --value=<domain> ```
stevensting marked this conversation as resolved
@@ -7,2 +7,4 @@
## Domain aliases
#EXTRA_DOMAINS=', `www.nextcloud.example.com`'
# same list as above but space separated
#EXTRA_DOMAINS_TRUSTED=cloud.coquest.coop
Owner

User the same alt example domain instead of coquest: www.nextcloud.example.com

User the same alt example domain instead of coquest: `www.nextcloud.example.com`
stevensting marked this conversation as resolved
@@ -71,3 +71,3 @@
- NEXTCLOUD_ADMIN_USER=${ADMIN_USER}
- NEXTCLOUD_ADMIN_PASSWORD_FILE=/run/secrets/admin_password
- NEXTCLOUD_TRUSTED_DOMAINS=${DOMAIN}
- EXTRA_DOMAINS_TRUSTED
Owner

I don't think this line is needed. EXTRA_DOMAINS_TRUSTED is already interpolated into NEXTCLOUD_TRUSTED_DOMAINS from .env at deploy time.

I don't think this line is needed. `EXTRA_DOMAINS_TRUSTED` is already interpolated into `NEXTCLOUD_TRUSTED_DOMAINS` from .env at deploy time.
stevensting marked this conversation as resolved
compose.yml Outdated
@@ -72,2 +72,3 @@
- NEXTCLOUD_ADMIN_PASSWORD_FILE=/run/secrets/admin_password
- NEXTCLOUD_TRUSTED_DOMAINS=${DOMAIN}
- EXTRA_DOMAINS_TRUSTED
- NEXTCLOUD_TRUSTED_DOMAINS=${DOMAIN} ${EXTRA_DOMAINS_TRUSTED}
Owner

From the docker-entrypoint.sh of Nextcloud, it looks like NEXTCLOUD_TRUSTED_DOMAINS is only applied on the first install (installed_version = 0.0.0.0) and not during restarts or upgrades.

So on an existing instance, this env var alone won't update the list. Needs a manual occ config:system:set trusted_domains Maybe add that as a comment to the .env.sample?

From the [docker-entrypoint.sh](https://github.com/nextcloud/docker/blob/583fbe383cedb716c7e8483e03b4d476992c6a7e/docker-entrypoint.sh#L215-L280) of Nextcloud, it looks like `NEXTCLOUD_TRUSTED_DOMAINS` is only applied on the first install (`installed_version = 0.0.0.0`) and not during restarts or upgrades. So on an existing instance, this env var alone won't update the list. Needs a manual `occ config:system:set trusted_domains` Maybe add that as a comment to the .env.sample?
stevensting marked this conversation as resolved
stevensting added 1 commit 2026-08-27 10:45:22 +00:00
stevensting added 1 commit 2026-08-27 10:48:16 +00:00
stevensting added 1 commit 2026-08-27 10:51:25 +00:00
Owner

Please add a short description to the PR comment.

Please add a short description to the PR comment.
Author
Owner

Please add a short description to the PR comment.

@ineiti should be good to go now

> Please add a short description to the PR comment. @ineiti should be good to go now
Owner

Aww - nextcloud really behaves badly here. I hate the "Only works on install", because it makes it so hard to debug if it fails later. I didn't find any way to update the configuration later. So let's hope people read the comments to the environment variables.

Also, if you have time to comment on #127 I would be really happy. Not sure if I just misunderstand, or if it's an actual issue.

Aww - nextcloud really behaves badly here. I hate the "Only works on install", because it makes it so hard to debug if it fails later. I didn't find any way to update the configuration later. So let's hope people read the comments to the environment variables. Also, if you have time to comment on #127 I would be really happy. Not sure if I just misunderstand, or if it's an actual issue.
Owner

Sorry - I didn't understand that EXTRA_DOMAINS and EXTRA_DOMAINS_TRUSTED is in fact the same information, just once for traefik and once for nextcloud. I thought that EXTRA_DOAMINS_TRUSTED was related to link nextcloud instances between themselves.

Also, I liked the suggestions from @dannygroenewegen and don't see them in the latest PR - did you discuss these with him?

Sorry - I didn't understand that `EXTRA_DOMAINS` and `EXTRA_DOMAINS_TRUSTED` is in fact the same information, just once for traefik and once for nextcloud. I thought that `EXTRA_DOAMINS_TRUSTED` was related to link nextcloud instances between themselves. Also, I liked the suggestions from @dannygroenewegen and don't see them in the latest PR - did you discuss these with him?
Author
Owner

Also, I liked the suggestions from @dannygroenewegen and don't see them in the latest PR - did you discuss these with him?

Add most of it to the readme to not flood the env file

> Also, I liked the suggestions from @dannygroenewegen and don't see them in the latest PR - did you discuss these with him? Add most of it to the readme to not flood the env file
Owner

Please change the relevant part of the .env.sample file to - this reduces some of the confusion I had when reading it the first time. Users don't read the README.md :(

DOMAIN=nextcloud.example.com
## Domain aliases - only evaluated on first startup!
# Comma-separated, backtick-quoted list for traefik
#EXTRA_DOMAINS=', `www.nextcloud.example.com`'
# Space separated list for nextcloud
#EXTRA_DOMAINS_TRUSTED=www.nextcloud.example.com
LETS_ENCRYPT_ENV=production
Please change the relevant part of the .env.sample file to - this reduces some of the confusion I had when reading it the first time. Users don't read the README.md :( ``` DOMAIN=nextcloud.example.com ## Domain aliases - only evaluated on first startup! # Comma-separated, backtick-quoted list for traefik #EXTRA_DOMAINS=', `www.nextcloud.example.com`' # Space separated list for nextcloud #EXTRA_DOMAINS_TRUSTED=www.nextcloud.example.com LETS_ENCRYPT_ENV=production ```
You are not authorized to merge this pull request.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin trusted-domains:trusted-domains
git checkout trusted-domains
Sign in to join this conversation.