If you are tired of trusting your personal files to companies like Google and Microsoft, companies that scan your data and can lock your account at any moment, it is time to take back control.
Nextcloud is the ultimate open-source alternative to Google Drive. It offers file sync, calendars, contacts, and notes, all hosted on your own hardware.
In this guide, I’ll show you the easiest way to install Nextcloud using Portainer.
1. Prerequisites
Before we start, you need a server running Portainer and a Reverse Proxy. If you don’t have these yet, follow my guides below:
- Install Portainer: https://libre-data.com/install-portainer/
- Install Nginx Proxy Manager: https://libre-data.com/install-npm/
2. The Docker Compose File
We will use the LinuxServer.io images for both Nextcloud and the MariaDB database. Using a dedicated database (MariaDB) instead of the built-in SQLite is critical for performance.
- Log in to Portainer.
- Go to Stacks -> Add stack.
- Name it
nextcloud. - Paste the following configuration:
services:
nextcloud:
image: lscr.io/linuxserver/nextcloud:latest
container_name: nextcloud
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Vienna
volumes:
- /mnt/nc-data/config:/config
- /mnt/nc-data/data:/data
ports:
- 444:443
restart: unless-stopped
mariadb:
image: lscr.io/linuxserver/mariadb:latest
container_name: nextcloud-mariadb
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Vienna
- MYSQL_ROOT_PASSWORD=amazingpassword
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=amazingpassword
volumes:
- /mnt/nc-data/sql:/config
ports:
- 3336:3306
restart: unless-stopped
Note: Make sure to change the passwords (amazingpassword) to something secure!
Click Deploy the stack and wait for the containers to start.
3. Initial Setup Wizard
Once the containers are running:
- Go to
https://<YOUR-SERVER-IP>:444in your browser. - Create your Admin account (username and password).
- Click on Storage & Database.
- Select MySQL/MariaDB.
- Fill in the details to match your compose file:
- Database user:
nextcloud - Database password:
amazingpassword - Database name:
nextcloud - Database host:
<YOUR-SERVER-IP>:3336(Do not use “localhost”, use the actual local IP of your server).
- Database user:
Click Finish Setup. Nextcloud will install.
4. Nginx Proxy Manager & DNS
To access Nextcloud via a nice domain name (e.g., nextcloud.home.arpa) with SSL, we need to configure the proxy.
- DNS: Create a DNS record on your router/firewall (like Pi-hole or OPNsense) pointing your desired domain to your Nginx Proxy Manager IP.
- NPM: Open Nginx Proxy Manager and create a new Proxy Host.
- Domain Names:
nextcloud.yourdomain.com - Forward Host:
<YOUR-SERVER-IP> - Forward Port:
444 - Scheme:
https
- Domain Names:
- Go to the Advanced tab in the Proxy Host window and paste this to fix upload limits and timeouts:
client_max_body_size 20G;
proxy_read_timeout 7200s;
proxy_connect_timeout 7200s;
proxy_send_timeout 7200s;
proxy_request_buffering off;
proxy_buffering off;
- Go to the SSL tab, request a new certificate (or use your existing one), and click Save.
5. Fixing “Untrusted Domain”
If you try to visit your new domain now, Nextcloud will likely block it with an “Untrusted Domain” error. We need to edit the config file manually.
- Go back to Portainer.
- Click on the Nextcloud container -> Console -> Connect.
- Run the following command to edit the config
nano config/www/nextcloud/config/config.php
- Look for the
trusted_domainsarray. - Delete the IP address line and replace it with your domain name, looking something like this:
'trusted_domains' =>
array (
0 => 'nextcloud.yourdomain.com',
),
- Press
Ctrl+X, thenY, thenEnterto save. - Restart the Nextcloud container.
You can now access your private cloud securely via your custom domain!
Video Guide
If you prefer a visual walkthrough, check out my YouTube video on this topic:

Hallo und guten Tag,
Ihre Anleitung zur Installation von Nextcloud hat bis zum Menü für die eigentliche Installation sehr gut funktioniert. Doch hier hakt es. Im Fenster Database-host habe ich 192.168.178.55:3336 eingesetzt und erhalte die Fehlermeldung: Error while trying to create admin account: An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user ‘nutzer’@’172.20.0.1’ (using password: YES)
Gebe ich einen anderen Port an erhalte von nginx den Fehler 504 und ein Timeout.
Bitte helfen Sie eienem Rentner auf die Sprünge. Bin für jede Hilfe dankbar.