OK, here's how I do it. not saying it's the only way, it's just simple and should have you up and running in about 15min. Everything that starts with a # needs to be adjusted for your system and then the # erased. Nothing other than those lines need to be changed despite what you've seen in other tutorials. All of the below assumes you have a basic understanding containers and command line (config paths, data paths, PUID/PGID, changing directories, nano, etc.)
You can use this in docker-compose or in a stack in portainer (I'd recommend using a stack as it will show if you have formatting errors):
version: "2"
services:
nextcloud:
image: ghcr.io/linuxserver/nextcloud:latest
container_name: nextcloud
environment:
#- PUID=1000
#- PGID=100
volumes:
#- /path/to/nextcloud/config:/config
#- /path/to/nextcloud/data:/data
- /etc/localtime:/etc/localtime:ro
depends_on:
- mariadb
ports:
- 450:443
restart: unless-stopped
mariadb:
image: ghcr.io/linuxserver/mariadb:latest
container_name: nextclouddb
environment:
#- PUID=1000
#- PGID=100
#- MYSQL_ROOT_PASSWORD=YOUR_MYSQL_PASSWORD
volumes:
#- /path/to/mariadb/config:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
swag:
image: linuxserver/swag
container_name: swag
cap_add:
- NET_ADMIN
environment:
#- PUID=1000
#- PGID=100
- DNSPLUGIN=duckdns
- URL=duckdns.org
#- DUCKDNSTOKEN=YOUR_TOKEN
#- SUBDOMAINS=YOUR_SUB_DOMAIN
- ONLY_SUBDOMAINS=true
- VALIDATION=http
#- EMAIL=YOUR_EMAIL
volumes:
#- /path/to/swag/config:/config
- /etc/localtime:/etc/localtime:ro
depends_on:
- nextcloud
ports:
- 457:443
- 91:80
restart: unless-stopped
Display More
This first part doesn't seem absolutely necessary, but for some reason I could never get it to work right unless I set it up locally first. I'm sure it was something I'm doing, I just can't figure out what..
1. Create all the directories and make all adjustments you need in docker-compose (you might want to delete old directories from previous attempts if you've been at this several times), then deploy the stack/docker compose file. If you use this set up exactly, in your router you'll need to make sure port 457 is forwarded to 443 and port 91 is forwarded to 80 (note: 457/91 are internal ports, 443/80 are external)
2. When done, go to nextcloud UI (https://your.omv.ip:450 , must use https and accept security risk)
3. Enter an admin user/password
4. Click setup database then mysql database
user root
password (see docker-compose, line 24 above)
database name: nextcloud
localhost: nextclouddb
5. Click Finish (this will take a few minutes as it downloads apps and sets up the database, be patient)
Once you're logged in you can complete a basic setup of Nextcloud, or move on to set it up with duckdns subdomains.
6. Navigate to /config/swag/nginx/proxy-confs
7. nano nextcloud.subdomain.conf.sample
8. Change subdomain to duckdns subdomain name (ie.. yoursubdomain.*, line 20 below)
## Version 2020/12/09
# make sure that your dns has a cname set for nextcloud
# assuming this container is called "swag", edit your nextcloud container's config
# located at /config/www/nextcloud/config/config.php and add the following lines before the ");":
# 'trusted_proxies' => ['swag'],
# 'overwrite.cli.url' => 'https://nextcloud.your-domain.com/',
# 'overwritehost' => 'nextcloud.your-domain.com',
# 'overwriteprotocol' => 'https',
#
# Also don't forget to add your domain name to the trusted domains array. It should look somewhat like this:
# array (
# 0 => '192.168.0.1:444', # This line may look different on your setup, don't modify it.
# 1 => 'nextcloud.your-domain.com',
# ),
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name yoursubdomain.*;
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
include /config/nginx/proxy.conf;
resolver 127.0.0.11 valid=30s;
set $upstream_app nextcloud;
set $upstream_port 443;
set $upstream_proto https;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
proxy_max_temp_file_size 2048m;
}
}
Display More
9. Save (Contrl x ) then Enter and and use backspace to erase the ".sample" extension. Hit enter then Y to save..
10. Restart swag container (docker restart swag)
11. Navigate to: /config/nextcloud/www/nextcloud/config
12. nano config.php
13. Under trusted domains array add your domain (you should see your local IP address there as 0), be sure to add it before the ),
1 => 'yoursubdomain.duckdns.org',
14. Add or edit the lines below, after the ), and before the );
'overwrite.cli.url' => 'https://yoursubdomain.duckdns.org',
'overwritehost' => 'yoursubdomain.duckdns.org',
'overwriteprotocol' => 'https',
When you're done, your config.php will look something like this (11, 23, 24, 25 are the lines I added in. A couple of those lines will already be there.. so you can either edit them as appropriate or delete them and add them in at the end like I did, either way just make sure there are no duplicates and it looks similar to the below)
<?php
$CONFIG = array (
'memcache.local' => '\\OC\\Memcache\\APCu',
'datadirectory' => '/data',
'instanceid' => 'oc3wozk6kai4',
'passwordsalt' => '2snos3M0EllfFy1CQH0Lah6kOEPyFC',
'secret' => 'it8C+qSyNcafTBLDp8nHQCAq9o/Fs9nUOgd/gYNFN5/Ro4pW',
'trusted_domains' =>
array (
0 => 'YOUR_LOCAL_IP:450',
1 => 'yoursubdomain.duckdns.org',
),
'dbtype' => 'mysql',
'version' => '20.0.6.1',
'dbname' => 'nextcloud',
'dbhost' => 'nextclouddb',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'oc_admin',
'dbpassword' => 'YfPeqGJ8LlsOIkXpgiEtf3bejjLtUK',
'installed' => true,
'overwrite.cli.url' => 'https://yoursubdomain.duckdns.org',
'overwritehost' => 'yoursubdomain.duckdns.org',
'overwriteprotocol' => 'https',
);
Display More
15. Save and close (Cntrl x then Y to save)
16. Restart the Nextcloud container docker restart nextcloud
17. Navigate to https://yoursubdomain.duckdns.org and log in.
This is optional, but once you're done and you can log in to your subdomain properly and securely... If you want to disable insecure access from your local network, go back to your docker-compose file or stack and make this adjustment under the "nextcloud" portion
ports:
- 450:443
to this
#ports:
#- 450:443
Then redeploy the stack or docker-compose file and you'll no longer have local access.
You're done.