Ramblings of an aging IT geek
← Ramblings of an aging IT geek
homelab

nextcloud, again, properly this time

A third attempt at self-hosting Nextcloud, this time on Postgres with Redis and a sensible reverse proxy instead of the all-in-one snap.

A server rack with cabling

This is my third go at Nextcloud. The first two ended the same way: a sluggish web UI, a sync client that quietly fell behind, and me eventually shrugging back to a folder on a NAS. The difference this time is that I stopped fighting the defaults and built it the way the docs actually want.

The thing that killed every previous attempt was SQLite. It works for about a week and one user, then the locking starts and every page load feels like it's wading through treacle. So Postgres from the start, Redis for file locking and caching, and PHP-FPM with OPcache turned up. None of this is clever. It's just the boring setup that everyone who runs Nextcloud happily is already running.

A homelab shelf with a few small machines

I'm running the official Docker image behind Caddy rather than the all-in-one appliance. The appliance is fine if you want it to own the whole box, but I already have a reverse proxy doing TLS for everything else and I'd rather not have two. The compose file is unremarkable:

services:
  app:
    image: nextcloud:29-fpm
    environment:
      POSTGRES_HOST: db
      REDIS_HOST: redis
    volumes:
      - ./data:/var/www/html
  db:
    image: postgres:16
  redis:
    image: redis:7

The bit that catches everyone, and caught me again, is the trusted domains and the overwrite.cli.url setting. If those are wrong the federation and the generated links point at the container's internal name and nothing makes sense. Set them in config.php and stop second-guessing it.

Background jobs were the other lesson. The default "AJAX" cron means jobs only run when someone loads a page, so on a quiet personal instance they basically never run. Switch it to a real cron, either a host crontab calling cron.php or a sidecar container, and suddenly previews generate, the trash empties, and the admin overview stops nagging you.

A day in, it's genuinely quick. File listings are instant, the Android client syncs without sulking, and I've turned off the bits I don't use so the dashboard isn't a wall of widgets. Whether it survives longer than the previous two attempts I won't know for a while, but for once the problem was me reaching for the easy installer rather than anything wrong with the software.