Taking Back Control of Your Files
Google Drive is convenient until it isn’t. Storage limits, subscription fees, and the quiet reality that your files sit on someone else’s servers have pushed a growing number of home lab enthusiasts and privacy-conscious users toward self-hosting. Nextcloud offers a full-featured alternative: a web interface, desktop sync clients, mobile apps, calendar and contacts sync, and a plugin ecosystem that rivals commercial offerings. The core difference is that the server runs on hardware you control, and the data never leaves it.
This guide walks through installing Nextcloud using Docker Compose on a Linux server or home lab machine, configuring it behind a reverse proxy, and getting your first users connected. If you are already running Docker on a VPS or local machine, most of this will feel familiar. If you are starting from scratch, you will need a machine running Ubuntu 22.04 or Debian 12, Docker, and Docker Compose installed before continuing.

Setting Up the Directory Structure and Environment File
Before writing any Docker configuration, create a dedicated working directory for the stack. Run mkdir -p ~/nextcloud && cd ~/nextcloud to get started. Inside that directory, create a file called .env to store credentials separately from your Compose file. This keeps passwords out of version control and makes future changes easier to manage. At minimum, define values for POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD, NEXTCLOUD_ADMIN_USER, and NEXTCLOUD_ADMIN_PASSWORD. Use long random strings for the database password – a password manager or openssl rand -base64 32 works well here.
Nextcloud performs noticeably better with PostgreSQL than SQLite, especially once you add multiple users or enable background jobs. SQLite is the default when Nextcloud auto-configures itself without a database container, so explicitly providing a PostgreSQL service in your Compose file prevents that fallback. Redis is also worth adding to the stack from the start – it handles file locking and session caching, and skipping it leads to database contention that shows up as slowness under even light load.
Writing the Docker Compose File
Create a file called docker-compose.yml in your working directory. The stack needs three services: db (PostgreSQL), redis, and app (Nextcloud). A fourth service for a cron job is optional but recommended for keeping background tasks running reliably without depending on browser-triggered calls.
For the db service, use the official postgres:15 image. Set the environment variables from your .env file using the env_file directive, and mount a named volume at /var/lib/postgresql/data to persist the database across container restarts. For the redis service, the redis:7-alpine image is sufficient with no special configuration needed.
The app service uses the official nextcloud:stable image. Map port 8080 on the host to port 80 inside the container – this is the port your reverse proxy will forward traffic to. Set environment variables for the database connection: POSTGRES_HOST=db, and the same DB name, user, and password from your .env file. Add REDIS_HOST=redis and NEXTCLOUD_TRUSTED_DOMAINS set to the domain or IP you plan to access Nextcloud from. Mount two volumes: one for the main Nextcloud data directory at /var/www/html, and one for user data at /var/www/html/data. If you have a large drive mounted elsewhere on the host, point the user data volume to that path rather than using a named Docker volume.
The optional cron service uses the same Nextcloud image but overrides the command with [“crond”, “-f”] and shares the same /var/www/html volume as the app container. It runs Nextcloud’s background jobs on a 15-minute schedule independently of web traffic. Add depends_on entries for db and redis in both the app and cron services so Docker Compose starts them in the correct order.

Putting Nextcloud Behind a Reverse Proxy
Accessing Nextcloud directly over HTTP on port 8080 works for local testing, but HTTPS is required for secure sync from mobile apps and desktop clients. A reverse proxy handles TLS termination and forwards traffic to the container. If you are already running Nginx Proxy Manager on the same host or network, adding a proxy host for your Nextcloud domain takes under two minutes – point it at localhost:8080 or your server’s LAN IP, enable the Let’s Encrypt certificate, and force HTTPS.
One setting that trips up many first-time Nextcloud setups is the overwrite protocol and host configuration. Even with HTTPS working at the proxy level, Nextcloud may generate internal links using HTTP because it does not know it is behind a proxy. Add the following lines to config/config.php inside the Nextcloud data volume: ‘overwriteprotocol’ => ‘https’ and ‘overwrite.cli.url’ => ‘https://your.domain.com’. You can also set these as environment variables in the Compose file using OVERWRITEPROTOCOL=https and OVERWRITECLIURL.
First Login and Essential Configuration
Navigate to your domain in a browser. If the containers started cleanly and the reverse proxy is routing correctly, you will see the Nextcloud setup screen on first load or the login page if the admin account was pre-configured via environment variables. Log in with the admin credentials you set earlier. The first thing worth doing is opening the Administration Settings panel and running the built-in security and setup warnings check. Nextcloud is thorough about flagging missing headers, misconfigured cron jobs, or PHP settings that affect performance.
Install the desktop sync client on your Mac or Windows machine from nextcloud.com/install. During setup, point the client at your domain and log in using the same admin account or a secondary user account you create for day-to-day use. Running everything as the admin account is fine for single-user setups but creates unnecessary risk on shared instances. The sync client works identically to Google Drive’s desktop app: a local folder on your machine stays in sync with the server, with status icons showing upload and conflict states.
The app store inside Nextcloud’s admin panel extends the platform well beyond file storage. Calendar and Contacts apps add CalDAV and CardDAV servers that sync with iOS, Android, and most desktop calendar apps. Nextcloud Talk adds video calling and messaging. Collabora Online or Nextcloud Office adds browser-based document editing for DOCX, XLSX, and PPTX files without sending them to a third party. None of these require anything beyond clicking install and refreshing the page – Docker handles the container side and the apps run inside the existing Nextcloud instance.





