How to setup NextCloud (file hosting) on your UGREEN NAS

One of the great features of having your own NAS is that you can run your own file server without paying for a hosted service or dealing with the limits of free tiers (like Google Drive).

Nextcloud is a popular file-hosting client–server application that you can easily install on your NAS.

In this guide, it will be installed as a Docker container from the command line, so before you proceed you need to be able to connect to your NAS via SSH (https://mozgc.blogspot.com/2025/05/how-to-connect-to-your-ugreen-nas-via.html) and have Docker installed.

After you have connected to your NAS via SSH, execute this command:
docker run -d \
  --name=nextcloud \
  -e PUID=1000 \
  -e PGID=10 \
  -e TZ=Etc/UTC \
  --publish 8080:80 \
-v /volume1/docker/nextcloud/config:/config \
  -v /volume1/docker/nextcloud/data:/data \
  --restart unless-stopped \
  lscr.io/linuxserver/nextcloud:latest
Breakdown of the command:

docker run Creates and starts a new container from the specified image.

-d Runs the container in detached mode (in the background, not attached to your terminal).

--name=nextcloud Assigns a human-readable name ("nextcloud") to the container for easier management (e.g., docker stop nextcloud).

-e PUID=1000 Sets an environment variable inside the container: PUID (Process User ID) = 1000. LinuxServer.io images use this to run internal processes as a specific user ID, matching a host user to avoid permission issues with mounted volumes.

-e PGID=10 Sets PGID (Process Group ID) = 10. Similar to PUID, this matches the group ID on the host (e.g., "wheel" or another group) for proper file access permissions.

-e TZ=Etc/UTC Sets the timezone environment variable to UTC, ensuring the container uses Coordinated Universal Time for logs, schedules, etc.

--publish 8080:80 (or -p 8080:80) Maps port 8080 on the host machine to port 80 inside the container. Nextcloud's built-in web server (typically Apache or Nginx in this image) listens on port 80 for HTTP traffic. You can access the Nextcloud web UI at http://your-host-ip:8080. (Note: The official LinuxServer example often uses 443:443 for HTTPS, but this variant uses plain HTTP on port 80 inside and exposes it on 8080.)

-v /volume1/docker/nextcloud/config:/config Mounts a host directory (/volume1/docker/nextcloud/config) to the container's /config path. This persists Nextcloud's configuration files, database (if using SQLite), themes, and app data across container restarts/upgrades.

-v /volume1/docker/nextcloud/data:/data Mounts another host directory (/volume1/docker/nextcloud/data) to /data inside the container. This stores users' actual files, uploads, and Nextcloud data directory persistently.

--restart unless-stopped Sets the restart policy: Docker automatically restarts the container if it stops (e.g., after host reboot or crash), unless you explicitly stop it with docker stop.

lscr.io/linuxserver/nextcloud:latest The image to use: The latest version of Nextcloud from LinuxServer.io's repository (multi-architecture support via lscr.io registry). This image includes Nextcloud pre-installed with common optimizations and uses Nginx + PHP-FPM.

Now we need to add the different addresses that will be used to access Nextcloud to the list of trusted addresses (for example, your local network IP, local hostname, external domain, etc.).

Another change that may be required is setting the overwritehost variable in the config file. Nextcloud’s automatic hostname detection can fail in some reverse proxy or CLI/cron scenarios, and this option lets you manually override it; for example www.example.com or www.example.com:8080.

To edit the config file, run the following command (replacing the path with your actual one):
nano /volume1/docker/nextcloud/config/www/nextcloud/config/config.php
Then edit the config file; here is how it looks on my machine:
<?php
$CONFIG = array (
  'overwritehost' => 'mydomain.net:8080',
  'datadirectory' => '/data',
  ...
  'trusted_domains' =>
  array (
    0 => 'ugreen:8080', // local network host
    2 => '192.168.1.256', // localip
    4 => 'mydomain.net:8080'
  ),
  'dbtype' => 'sqlite3',
  'version' => '31.0.6.2',
  'overwrite.cli.url' => 'http://ugreen:8080',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\APCu',
  'upgrade.disable-web' => true,
);

Finally, restart the container:
sudo docker restart nextcloud                                  
Now your Nextcloud server should be accessible on port 8080, for example: http://192.168.1.50:8080, or http://MyUgreenNas:8080, or http://MyDomain.net:8080, etc.

Now you and your friends can install Nextcloud by downloading it from here and enjoy free, unlimited file hosting.

Comments

Popular posts from this blog

How to set up a simple backup on your UGREEN NAS using rsync & cron scheduler

How to connect to your UGREEN NAS via SSH

Fixing low brightness (darkness) in 4K HDR movies