Pointers for Docker Newbie - NextCloud

Discussion about Docker
Locked
User avatar
StephenM
Posts: 71
Joined: 11 Jan 2021, 21:55
Great Britain

Pointers for Docker Newbie - NextCloud

Post by StephenM »

Hi.

I'm stumbling around in the dark a bit here and with a few minutes of someone's time they might point me in the right direction.

I've installed the Docker app from the Apps from the desktop.

I've grabbed this image : https://hub.docker.com/r/linuxserver/nextcloud/
Using:

Code: Select all

docker pull ghcr.io/linuxserver/nextcloud
This now shows up in the Docker App, under images.
Should I launch this in the Docker App and fill in various parts of the forms associated with this, based on this data from the nextcloud site above:

Code: Select all

---
version: "2.1"
services:
  nextcloud:
    image: ghcr.io/linuxserver/nextcloud
    container_name: nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
    volumes:
      - /path/to/appdata:/config
      - /path/to/data:/data
    ports:
      - 443:443
    restart: unless-stopped
Should I start from the CLI based on this

Code: Select all

docker run -d \
  --name=nextcloud \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Europe/London \
  -p 443:443 \
  -v /path/to/appdata:/config \
  -v /path/to/data:/data \
  --restart unless-stopped \
  ghcr.io/linuxserver/nextcloud
Or should I use the docker-compose method (Using the first set of parameters). Reading this recipe it seems I need to create some other folders and files which I'm not too sure about where exactly to create the directories etc. https://docs.docker.com/compose/gettingstarted/

My guess would be that the bulk of the work in this recipe should have been done. Do I need to find the directory and create the docker-compose.yml file there and then issue a

Code: Select all

docker-compose up

Code: Select all

volumes:
      - /path/to/appdata:/config
      - /path/to/data:/data
Where is the app data path - Is this simple /mnt/appdata or do I need to work out where the correct path for nextcloud is?
Where is the data path - Should I be creating a new directory for this?

Is there other work that needs doing - Installing a web server or adding SSL or similar?

If anyone has done this and they can point me in the right direction I would be very grateful.

Thanks
Steve
User avatar
StephenM
Posts: 71
Joined: 11 Jan 2021, 21:55
Great Britain

Re: Pointers for Docker Newbie - NextCloud

Post by StephenM »

Right....

Passing over the above, which would still be interesting to note...

I searched in the Docker app for NextCloud and installed the most popular one found.

I didn't change any of the settings and it started just fine - It mapped a random port to port 80 and when I used Safari to connect to the address of my NAS with the random port I get the installation wizard.

Reading the warning about not using SQLite I decided to install Maria from the App store on the NAS desktop.

Try as I might I could not get the wizard past this point when using a Maria Database.

Selecting the MySQL/Maria DB in the wizard and entering a mixture of options I failed to get any progress. Using localhost and port 3306 did nothing.
Using the LAN IP address of the NAS box and port 3306 it seemed to do something for a while and then timed out. Ive tried with the root user for Maria and have verified that I can access the MySQL database from my laptop with the root user (I had to tweak to get that to work).

Still no joy. I can only assume I must be missing something in terms of getting it to connect - Some PHP libraries perhaps?

When I asked it to go ahead with an SQLite database (which isn't recommended for a production system) it all created fine and then gave me a web UI.

Any idea what I've been doing wrong?

If I'm only planning on having a maximum of 4 users for the NextCloud will SQLLite be powerful enough or should I bin it off and start again and try and resolve my Maria DB connectivity problems.
User avatar
mukmuk
Posts: 24
Joined: 08 Jan 2021, 21:39

Re: Pointers for Docker Newbie - NextCloud

Post by mukmuk »

How did you install the MariaDB server? Through docker, through the TOS Appstore, docker-compose, ...?

Keep in mind, that the nextcloud instance has a separate virtual IP set up by docker. This depends on how you created the docker container. If you created the container by "docker run" or through the TOS Docker-App, it should use the default bridge. You can grab the network info by

Code: Select all

docker network inspect bridge
- look for the gateway ip. That's the one where the nextcloud container can reach the docker host (as in your NAS). If your mariadb server is running on your host, you can use the gateway ip. If your mariadb server runs through docker, it should have its own ip assigned on the bridge.
User avatar
StephenM
Posts: 71
Joined: 11 Jan 2021, 21:55
Great Britain

Re: Pointers for Docker Newbie - NextCloud

Post by StephenM »

Hi all.

I've made some progress, but not all the way to a working NextCloud sitting behind and SSL reverse proxy.

It feels like I’m not a million miles away from having Next Cloud running on my NAS server behind a reverse proxy accessible from the internet.

My Router NAT IP - 192.168.1.254
My NAS IP - 192.16.1.100

I have correctly installed NextCloud and got it up and running using the following docker-compose.yml

Code: Select all

version: ‘2’

volumes:
nextcloud:
db:

services:
db:
image: mariadb
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpwd
- MYSQL_PASSWORD=userpwd
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud

app:
image: nextcloud
restart: always
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html
environment:
- MYSQL_PASSWORD=userpwd
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=db
- VIRTUAL_HOST=nextcloud.mydomain.net
- LETSENCRYPT_HOST=nextcloud.mydomain.net
- [email protected]
(I’m not sure the last 3 lines are needed as that was when I was trying to set up a proxy in a different way)

docker-compose up -d starts everything and I can log into the NextCloud console (after creating an admin user) vi the LAN IP address of my Terra-master : http://192.168.1.100:8080 from my PC on the same subnet.

I have set-up Nginx Proxy Manager following this recipe:
https://nginxproxymanager.com

My exact docker-compose.yml looks like this:

Code: Select all

version: “3”
services:
app:
image: ‘jc21/nginx-proxy-manager:latest’
restart: always
ports:
# Public HTTP Port:
- ‘80:80’
# Public HTTPS Port:
- ‘443:443’
# Admin Web Port:
- ‘81:81’
environment:
# These are the settings to access your db
DB_MYSQL_HOST: “db”
DB_MYSQL_PORT: 3306
DB_MYSQL_USER: “npm”
DB_MYSQL_PASSWORD: “userpasswd”
DB_MYSQL_NAME: “npm”
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
- ./config.json:/app/config/production.json
depends_on:
- db
db:
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: ‘rootpasswd’
MYSQL_DATABASE: ‘npm’
MYSQL_USER: ‘npm’
MYSQL_PASSWORD: user’userpasswd’
volumes:
- ./data/mysql:/var/lib/mysql

This is a bit of a pain to get working: docker-compose up -d, then docker-compose down. Delete the directory that it’s created (./config.json) and then create a file ./config/json and add the following details:

Code: Select all

{
“database”: {
“engine”: “mysql”,
“host”: “db”,
“name”: “npm”,
“user”: “npm”,
“password”: “userpasswd”,
“port”: 3306
},
}
And then do a docker-compose up -d again.
The Nginx proxy manager starts after a bit of waiting and then you can access on 192dot168dot1dot100:81.

Continued.....
Last edited by StephenM on 14 Jan 2021, 01:04, edited 2 times in total.
User avatar
StephenM
Posts: 71
Joined: 11 Jan 2021, 21:55
Great Britain

Re: Pointers for Docker Newbie - NextCloud

Post by StephenM »

I have DNS settings - netcloud.mydomain.net set up as a CNAME to DDNS domain other.domain.com and my router is set up to forward ports 80 and 443 to 192.168.1.100:80 and :443 respectively.

I have set up a proxy hosts rule in Nginx proxy manager to:
Listen on port 443, use LetsEncrypt (which created a certificate without problems - with the force SSL option) and forward that port to http://192.168.1.100:8080 (the working NextCloud port)

I’ve added the following to the NextCloud config.php:

Code: Select all

‘trusted_domains’ =>
array (
0 => ‘192.168.1.100:8080’,
1 => ‘nextcloud.mydomain.net’,
2 => ‘UNRAID IP:PORT’,
),
I’m not sure about 2 - followed that from another recipe somewhere

Code: Select all

‘trusted_proxies’ =>
array (
0 => ‘192.168.1.0/24’,
1 => ‘172.18.0.0/16’,
),
The second one is the IP subnet of the proxy container.

Code: Select all

‘forwarded_for_headers’ =>
array (
0 => ‘X-Forwarded-For’,
1 => ‘HTTP_X_FORWARDED_FOR’,
),
I the restarted the NextCloud with docker-compose down and docker-compose up -d

However - When I connect to http://nextcloud.mydomain.net the proxy server returns a 504 gateway timeout (after a delay) with this appearing in the proxy error log:

Code: Select all

2021/01/13 14:54:48 [error] 4522#4522: *1127 upstream timed out (110: Operation timed out) while connecting to upstream, client: 192dot168dot1dot254, server: nextcloud.mydomain.net, request: “GET / HTTP/2.0”, upstream: “http://192.168.1.100:8080/”, host: “nextcloud.mydomain.net”
I’ve also tried modifying the rule config file as outlined at the bottom of this article https://shollyethan.medium.com/configur ... 0b5175fba2

Replacing

Code: Select all

include conf.d/include/proxy.conf
with

Code: Select all

add_header X-Served-By $host;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass https://$server:$port;
Iv’e tried the last line as http as well as the https documented.

However, if I change my port forwarding on the router to map port 80 to 192.168.1.100:8080 (insecure just done for a test) then a http://nextcloud.mydomain.net connects and allows me to log in.

Also if I put my port forwarding back on the router to map port 80 to 192.168.1.100:80 and change the Nginx proxy manager rule to map 192.168.1.100:433 to 192.168.1.254:80 sticking https://nextcloud.mydomain.net into a browser gives my router login page.

Any suggestions gratefully received.
User avatar
StephenM
Posts: 71
Joined: 11 Jan 2021, 21:55
Great Britain

Re: Pointers for Docker Newbie - NextCloud

Post by StephenM »

mukmuk wrote: 13 Jan 2021, 03:56 How did you install the MariaDB server? Through docker, through the TOS Appstore, docker-compose, ...?

Keep in mind, that the nextcloud instance has a separate virtual IP set up by docker. This depends on how you created the docker container. If you created the container by "docker run" or through the TOS Docker-App, it should use the default bridge. You can grab the network info by

Code: Select all

docker network inspect bridge
- look for the gateway ip. That's the one where the nextcloud container can reach the docker host (as in your NAS). If your mariadb server is running on your host, you can use the gateway ip. If your mariadb server runs through docker, it should have its own ip assigned on the bridge.
Thanks. I didn't know that.
User avatar
StephenM
Posts: 71
Joined: 11 Jan 2021, 21:55
Great Britain

Re: Pointers for Docker Newbie - NextCloud

Post by StephenM »

I've got it working.

Would anyone like a recipe writing for the forum?

If the answer's yess I'll do it tomorrow.
Locked

Return to “Docker”