Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a mechanism to set trusted domains on install #500

Merged
merged 2 commits into from
Oct 15, 2018

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented Oct 12, 2018

Resolves #469

Optionally, NEXTCLOUD_TRUSTED_DOMAINS can be specified. After sucessfull install, occ is being used to set the provided domains names.

for example:

$ sudo docker run -e SQLITE_DATABASE=foobar -e NEXTCLOUD_ADMIN_USER=adm -e NEXTCLOUD_ADMIN_PASSWORD=dma -e NEXTCLOUD_TRUSTED_DOMAINS=foo.bar\ barfoo.com f7469ede5323
Initializing nextcloud 14.0.2.2 ...
Initializing finished
New nextcloud instance
Installing with SQLite database
starting nexcloud installation
creating sqlite db
Nextcloud was successfully installed
setting trusted domains…
System config value trusted_domains => 1 set to string foo.bar
System config value trusted_domains => 2 set to string barfoo.com
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Fri Oct 12 12:46:54.210310 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.10 configured -- resuming normal operations
[Fri Oct 12 12:46:54.210354 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
$ sudo docker exec -it c0cfa5a94c19 /bin/bash
root@c0cfa5a94c19:/var/www/html# cat config/config.php 
<?php
$CONFIG = array (
…
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'foo.bar',
    2 => 'barfoo.com',
  ),
…
);

@SnowMB
Copy link
Contributor

SnowMB commented Oct 12, 2018

hey thanks for your contribution. Unfortunately the files you edited aren't meant to be edited directly. They are auto generated from the docker-entrypoint.sh in the root directory via the update.sh script. You should apply your changes in that file and run ./update.sh afterwards.

@SnowMB SnowMB added the image label Oct 12, 2018
@blizzz
Copy link
Member Author

blizzz commented Oct 12, 2018

ah, good to know :) I'll adjust next week, thanks for the pointer!

@blizzz blizzz force-pushed the feature/649/set-trusted-domains branch from b6d2906 to e0e9dc9 Compare October 15, 2018 09:47
@blizzz
Copy link
Member Author

blizzz commented Oct 15, 2018

@SnowMB done

@SnowMB
Copy link
Contributor

SnowMB commented Oct 15, 2018

Thanks!

There is a version bump in the nextcloud 14 image.
I think this should be excluded from this feature addition and rebased on the master after the version is updated.

@tilosp Can you have a look?

@blizzz
Copy link
Member Author

blizzz commented Oct 15, 2018

There is a version bump in the nextcloud 14 image.

14.0.3 is the currently released version. I don't know how updates are picked up here, manually or (semi-)automatically?

@tilosp
Copy link
Member

tilosp commented Oct 15, 2018

A simple rebase onto master should fix this (You branched before 4d2dbd6)

@blizzz blizzz force-pushed the feature/649/set-trusted-domains branch from e0e9dc9 to 1f4ffe7 Compare October 15, 2018 13:30
@blizzz
Copy link
Member Author

blizzz commented Oct 15, 2018

A simple rebase onto master should fix this (You branched before 4d2dbd6)

Check!

NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN"
Copy link
Member

@tilosp tilosp Oct 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break if you put special characters into this var. (like " or $)
But it shouldn't really matter because a valid domain name can't contain these characters.

Copy link
Member

@tilosp tilosp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tilosp tilosp merged commit 3838458 into master Oct 15, 2018
@tilosp tilosp deleted the feature/649/set-trusted-domains branch October 15, 2018 17:57
@tilosp
Copy link
Member

tilosp commented Oct 15, 2018

Thanks for your contribution :)

@mvillarejo
Copy link

thank you for this contribution!

@bernd-protofy
Copy link

my configuration does not work, could somebody help me?

this is my 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…"

is mariadb not supported?
thx for any help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants