Homelab: my secure personal cloud on a Raspberry Pi 5

Homelab: my secure personal cloud on a Raspberry Pi 5


DevSecOps
Docker DevSecOps Raspberry Pi TypeScript

Brief

A personal server on a Raspberry Pi 5 that replaces five subscriptions: photo storage, file storage, music streaming, video streaming and a VPN. It runs 18 Docker containers. Nothing is directly exposed to the Internet, two-factor authentication guards the entrance, backups are verified, and recovery has been proven in real conditions. The music part relies on aubi, an app I designed and built.

Table of contents

Where it started

It started because I was tired of paying every month for:

  • iCloud+ to store my photos;
  • Google One to store my files;
  • Spotify to listen to… albums I already own on CD and vinyl;
  • Netflix for movies and TV shows;
  • a commercial VPN to stay safe on public Wi-Fi.

That adds up to roughly €610 a year, every year, to rent access to things I own. My data lived with five different companies under their terms, and my music and movies would vanish the day I stopped paying.

On the other side, the hardware cost me €50, once: the Raspberry Pi 5 came from a second-hand listing for €45, and the 500 GB drive from a flea market for €5. Add roughly €1 of electricity per month. It pays for itself in a single month of subscriptions.

Comparison: five subscriptions (cloud, music and video streaming, VPN), about €610 a year, versus a second-hand Raspberry Pi 5 and a flea-market drive, €50 once

Indicative amounts: they depend on the chosen plans.

Beyond the money, I wanted it to be at least as safe as the services I was replacing. That is actually what took the most work.

Goals

  1. Replace all five services without losing comfort: automatic photo backup from the phone, files available anywhere, music on mobile with the screen locked, movies on the TV and the phone, and a VPN for public Wi-Fi.
  2. Expose nothing: no open port on the router, and strong authentication before reaching any service.
  3. Describe everything as code: the whole configuration lives in a git repository, which makes the server rebuildable.
  4. Be able to lose everything but the data: the hardware must be disposable, the data must not be.

Architecture

Architecture diagram: Internet, Cloudflare Tunnel, Traefik, Authelia, then the Raspberry Pi 5 and its Docker services; WireGuard VPN access alongside

There are only two ways in:

  • The web path. The Pi itself opens an outbound connection to Cloudflare (Cloudflare Tunnel). An Internet request rides that tunnel to Traefik, the reverse proxy, which terminates HTTPS and has Authelia check the user’s identity before routing to the right service. The router has no open port at all, which suits me: my line sits behind a CGNAT that would not let me open one anyway.
  • The VPN path. WireGuard gives direct access to the home network from my phone or laptop, over IPv6. It runs as a full tunnel: all of the device’s traffic goes through home, and its DNS queries through Pi-hole. A small script updates the DNS record whenever the ISP changes the IPv6 prefix.

Storage is split in two. The SD card holds the system and the Docker engine. The 500 GB drive holds everything that matters: photos, media, databases, configuration and backups.

18 containers run on an 8 GB Raspberry Pi 5. Heavy jobs are tuned for this machine: for example, Immich’s image recognition is disabled and its thumbnail generation is capped at two cores.

My own VPN, no subscription

A commercial VPN mostly does two things: protect your connection on public Wi-Fi, and block some ads and trackers. The homelab does both.

  • WireGuard (through wg-easy) as a full tunnel: from the phone or laptop, all traffic travels encrypted to my home, then goes out through my own connection. On station or hotel Wi-Fi, nobody on the network can see what I browse.
  • Pi-hole as the DNS server for VPN clients: ads and trackers are blocked before they even load, in every app, including on 4G.
  • Each device has its own profile, created from a web UI and imported by scanning a QR code. A lost device is revoked in one click.

That said, a home VPN will not let you “change country”, since traffic always leaves through my own connection. That is fine by me: what I wanted was security on public networks and ad blocking.

Movies: Jellyfin instead of Netflix

Jellyfin is a free media server. It indexes my movies, shows, documentaries and vlogs, fetches posters and synopses, remembers where I stopped, and has apps for phone, computer and TV. Files are played as-is whenever possible, since the Pi 5 has no hardware video encoder. Like everything else, Jellyfin sits behind Authelia.

The catalog does not change from one month to the next, since these are my own files.

Security: defense in depth

The five security layers: network, transport, identity, containers, data

The idea is to never rely on a single protection: if one fails, the next one takes over.

  1. Network: no open port on the router, an outbound tunnel for the web, and a WireGuard VPN for direct access.
  2. Transport: HTTPS everywhere with Let’s Encrypt certificates issued and renewed automatically through a DNS challenge. Security headers apply to every service: two-year HSTS, nosniff, no framing, strict Referrer-Policy.
  3. Identity: Authelia sits in front of the services with a default-deny policy, SSO and TOTP two-factor authentication. A password can leak through reuse, phishing or another site’s breach. With 2FA it is no longer enough: you also need the six-digit code from an app on my phone, which changes every 30 seconds. Since one login then opens the whole homelab (SSO), the extra security costs almost nothing in comfort.
  4. Containers: databases live on internal Docker networks with no route to the Internet. Sensitive containers run with no-new-privileges, the Docker socket is mounted read-only where it only needs to be read, and CPU and RAM caps keep a runaway service from taking the others down.
  5. Data: secrets live in a .env file with 600 permissions, kept out of git. A nightly backup dumps the databases and archives the configuration, and every archive is verified, with 14 days of rotation.

A DevSecOps approach

The DevSecOps loop: version, build, deploy, monitor, back up, restore

I used the same habits as at work, on a smaller scale:

  • Infrastructure as Code: the whole server is described in a versioned docker-compose.yml, with every non-obvious choice explained in a comment.
  • Controlled versions: critical components are pinned. Watchtower reports available updates but never applies them blindly.
  • Ordered deployment: every service has a healthcheck, and services wait until their database is actually ready.
  • Observability: Uptime Kuma watches every service, and Homepage gives an overview.
  • Security by design: default deny, least privilege, secrets out of the code, minimal attack surface.
  • Tested recovery: a backup is useless if you cannot restore it. I got to test mine sooner than planned.

Real incident: the SD card failure

Recovery timeline after the SD card failure, until all 18 services were back

The old Raspberry Pi 4’s SD card eventually died: the machine would not boot, and the card was unreadable. Luckily, I had planned for this from the start.

  1. New hardware: a Raspberry Pi 5, an official 27 W power supply and a fresh card, flashed with key-only SSH access.
  2. The drive was remounted at the same path: photos, media, configuration and the git repository were all intact.
  3. docker compose up: the stack came back from its own description.
  4. Three fixes caused by the newer system:
    • Docker 29 rejects old API versions, so Traefik could no longer see the containers. I fixed it on the Docker daemon side, without touching the stack.
    • The new kernel no longer ships legacy iptables, so I switched the VPN rules to nftables.
    • Raspberry Pi OS disables container memory control by default, so the RAM caps were being silently ignored. I re-enabled it at boot.
  5. Full check after a reboot: drive, network, VPN, all 18 services healthy.

In the end, it took me one afternoon, without losing a single photo. The only loss was Nextcloud’s almost empty database, which had stayed in a Docker volume on the SD card. My takeaway: everything that matters belongs on the drive, not on the SD card.

aubi, my music player

How aubi works: audio files, scanner, NestJS API and PostgreSQL, streaming, mobile app

To replace Spotify, I needed a player for my music with the comfort of a streaming app. I could not find one I liked, so I built my own: aubi. It is open source and available on my GitHub: github.com/Claquettes/aubi.

aubi reads audio files from a folder (MP3, FLAC, OGG, Opus, M4A, WAV) and serves them through a web app that runs on iOS and Android, right in the browser:

  • artwork-driven colors: every page takes on the colors of its album cover;
  • playlists, favorites, resume playback, with Music, Concerts and Audiobooks sections;
  • listening statistics and a graph of artists linked by their collaborations;
  • tag editing from the UI, written into the files themselves, with a backup copy of the original file;
  • lock-screen and notification-center controls (Media Session).

Under the hood: React + TypeScript on the front end, NestJS + PostgreSQL on the back end, audio streamed through Range requests, all running in Docker behind Traefik and Authelia like the rest of the homelab.

A development story: on iPhone, music stopped when the screen locked. To animate the player to the beat, audio was routed through a Web Audio analyser, and iOS suspends that context in the background and never resumes it. The fix disables the analysis on iOS, where the animation falls back to pure CSS. It shipped the same way as everything else: branch, pull request, merge, redeploy.

Results

  • ≈ 28,000 photos and videos in Immich;
  • ≈ 2,600 tracks in aubi;
  • 18 services, 0 open ports on the router;
  • €50 of second-hand hardware, versus ≈ €610 of subscriptions per year;
  • 5 fewer subscriptions;
  • 1 real outage, absorbed in an afternoon.

Limitations and next steps

  • Backups sit on the same drive as the data. They protect against mistakes and corruption, not against the drive dying. Next step: an off-site copy, in the spirit of the 3-2-1 rule.
  • The SD card is still a weak spot. I plan to move Docker data onto the drive, then boot the Pi from an NVMe SSD.
  • No CI for the infrastructure yet. Automatic configuration checks (compose linting, image scanning) would belong here.
  • Hardware limits. Immich’s image recognition stays disabled because it is too heavy for the Pi.
© 2026 Mathieu Ponton | Co-Founder & ingénieur logiciel @ Apogée Consult | Lyon, France