Back

How to Self Host Nextcloud With Docker and Caddy (and Get Alarmed When It Goes Down)

A working Nextcloud on your own server in about an hour, built from the project's official docs. Then the part most guides skip: making sure something outside that server tells you when it dies.

Jagdish Patil

•

What you're setting up, and what it needs

Nextcloud replaces Google Drive, Dropbox and a few other subscriptions with files, calendar and contacts on a server you control. There are two common ways to run it in Docker. You can hand roll a Compose stack with Nextcloud, a database and Redis, which is what most tutorials show. Or you can use Nextcloud AIO, short for All in One, which Docker Hub describes as the official Nextcloud installation method.

We use AIO here. It starts one master container that creates and manages the rest of the stack, includes a PostgreSQL database, offers optional extras such as Nextcloud Office and Talk, and runs daily backups and updates from a web interface. Hand rolling gives you more control over versions, but you also own database tuning and every upgrade. If you do hand roll, install on PostgreSQL from the first boot. SSD Nodes calls SQLite fine for a demo and a trap in production.

You need four things:

  • A Linux server with Docker, whether a VPS or a box at home.

  • A domain or subdomain, such as cloud.example.com, pointing at the server's IP.

  • Ports 80 and 443 reachable from the internet. Behind CGNAT this is impossible, and we cover the workaround below.

  • Enough memory. We can't quote an official figure here, so check the AIO README for current requirements. As a rough guide, a hosting provider's roundup puts Nextcloud, n8n and Immich in the 2 to 4 vCPU and 4 to 8 GB RAM bracket.

Step 1: Install Docker and point your domain

Create an A record for cloud.example.com that points at your server's public IP. Then install Docker on the server. Docker's own install page is the reference, and Docker Hub's AIO page suggests the convenience script:

Step 2: Put Caddy in front

AIO's reverse proxy documentation marks Caddy as the recommended option, and Caddy gets and renews HTTPS certificates for a public domain on its own. Install Caddy on the host using Caddy's install docs, then add this to your Caddyfile, swapping in your own domain:




Port 11000 is where AIO's Apache container will listen. Reload Caddy after saving.

Step 3: Start AIO with the reverse proxy command

The AIO docs give a specific startup command for running behind a reverse proxy. This is it, from the reverse proxy page with one change we explain below:




The docs' main example sets APACHE_IP_BINDING to 0.0.0.0. Their step 3 says that if Caddy runs on the same host and you point it at localhost, you should use 127.0.0.1 so nothing outside the machine can reach the Apache container directly. If your reverse proxy runs in a container or on another machine, use 0.0.0.0 as the docs show.

One registry note. Some current copies of the AIO README list the image as ghcr.io/nextcloud-releases/all-in-one:latest instead of the Docker Hub name. If the README you're looking at says that, use it.

Step 4: Finish in the AIO interface

Open https://your.server.ip:8080, using the IP address and not your domain. The docs warn that HSTS can lock you out of the port later if you use a domain, and the page uses a self signed certificate, so your browser will complain. That's expected.

Enter the domain you used in the Caddyfile and pick any optional containers you want. Open ports 3478 over TCP and UDP in your firewall if you plan to use Talk. Then start the containers and wait. The first run pulls a lot of images.

When it finishes, https://cloud.example.com should show the Nextcloud login page.

The gotchas that actually bite

You're behind CGNAT. If your home ISP shares one public IP between customers, you can't open ports properly. The AIO docs point you to a Cloudflare Tunnel, which they treat like a reverse proxy. You also add --env SKIP_DOMAIN_VALIDATION=true to the startup command, because validation can't work through a tunnel. Switch off Cloudflare's Rocket Loader feature too, or the login prompt won't appear.

Domain validation fails. The docs' debug list is worth following in order. Check that APACHE_PORT matches the port in your Caddyfile, that ports 80 and 443 are open, and that you used the reverse proxy startup command rather than the default one. If it still fails, read the logs with sudo docker logs nextcloud-aio-mastercontainer.

Backups. AIO can run daily backups from its interface. When you enable them, choose a location that isn't the same disk Nextcloud lives on. A backup on the disk that dies is a decoration.

Updates. AIO updates its containers, Nextcloud and its apps from the same interface. Read the AIO README for when backups and updates restart containers, then schedule them for a time when a short outage is fine.

Self signed certificates. AIO doesn't support them for Nextcloud itself. Use a real certificate through Caddy.

Why the monitor on the same server can't save you

You'll hear that you should just run Uptime Kuma next to Nextcloud. It's a fine tool. It checks HTTP, TCP, ping, DNS and more, with intervals as short as 20 seconds, and a lot of self hosters rely on it. We're not here to argue otherwise.

The weak spot is where it runs. A monitor on the same box dies with the box, and a monitor on your home network goes silent when your home internet drops, which is exactly when your files become unreachable. The README of secwatch, a self hosted security monitor, says this plainly: its own alerts can't fire if it's dead, so it pings an external monitor and lets that monitor alert when the pings stop.

That outside watcher is the job SIOPS does. We check your URL from our probe network on the public internet, so a dead server, a dead home connection and a broken certificate all look the same to us: the page didn't answer.

Watch Nextcloud with SIOPS

Nextcloud ships a small status endpoint at /status.php. In the server source it returns JSON with installed, maintenance, needsDbUpgrade and the version, and it answers with an HTTP 500 if something throws an exception. That makes it a good first monitor, because it only answers when the web server, PHP and Nextcloud's code are all working.

  1. Add a monitor for https://cloud.example.com/status.php.

  2. Add a second one for https://cloud.example.com/, the page your users actually see.

  3. Give them an alarm tone you'll recognise.

  4. Set the alert to a native alarm, and acknowledge it from the lock screen when it fires.

The alarm uses the same channel as your morning alarm clock: iPhone Critical Alerts on iOS and the alarm channel on Android. Silent mode and Do Not Disturb don't swallow it. There's no agent to install on your server, because a monitor is just a URL.

One honest caveat. During maintenance, status.php reports maintenance: true in its JSON instead of failing, so a plain URL check stays green. That's convenient during an AIO update, but it also means a Nextcloud stuck in maintenance mode won't set off the alarm. Check it yourself after updates with the occ status command from Nextcloud's admin docs.

Here's what the plans cover:


Plan

Sites

Alarms

Polling

Price

Hobby

5

1

5 minutes

Free

Serious

10

Unlimited

60 seconds

$3.75 a month per project, billed monthly

The yearly toggle on the Serious plan shows a 20 percent saving. With unlimited alarms on Serious, each monitor can carry its own alarm tone, so when you watch your own Nextcloud and a few client sites you know which one failed before you open the app. Each monitored site gets a public status page on a siops.app subdomain too, handy if teammates or clients keep asking whether the files are up.

SIOPS can only see what the internet can see. If Nextcloud lives only on your home network, we can't reach it, and you'd need a reverse proxy or tunnel first. We'll also tell you that the page didn't answer, not why. When the alarm goes off, run the docker logs command above and start there.

You can set it up free at siops.app.

Similar Stories

Similar Stories