Zheer Karwany
All projects

Homelab

A private, self-healing home server. 16 containers, zero ports open to the internet.

It started as "run Jellyfin at home" and turned into a small, carefully run platform: 16 containers in 3 Docker Compose projects on Ubuntu, reachable only through a Tailscale mesh VPN. Private DNS and a reverse proxy give every service a clean hostname without opening a single port on my router. Along the way I've debugged boot-order race conditions, a Docker networking failure after power loss, a lockout during an internet outage, and malware hiding in an automated download pipeline. Each one ended with a permanent, tested fix and a written post-mortem.

Live since spring 2026, used daily Private by design Designed, built and run by me
containers, in 3 Compose projects
16
ports open to the internet
0
private hostnames, no wildcard
13
boot-order fixes, reboot-tested
3
releases of my own app
5
runbooks in the docs vault
13

What I set out to build

I wanted my own streaming, file storage and photo library instead of paying for several subscriptions and handing personal files to other companies. These were my hard requirements:

  • Nothing exposed to the public internet: no router port forwards and no rented server. Only my own devices get in, over an encrypted VPN.
  • Clean, memorable addresses under my own domain instead of IP addresses and port numbers, and still private.
  • It survives power cuts and reboots without me fixing anything by hand.
  • It stays usable on home Wi-Fi when the internet is down.
  • Every change is backed up, reversible and written down.

How it fits together

Select any part of the diagram to see what it does, or follow one request from my phone to a service and back.

Follow a request

Press "Start" to follow what happens when I open one of my services, step by step.

Solid lines travel through the VPN. The dotted line is the home Wi-Fi fallback, which only reaches the web interfaces.

What happens when the power comes back

Each step waits for the one before it. Every one of these ordering rules is a systemd rule I added after a real incident.

  1. Media disk mountsDocker may not start before it
  2. Encrypted archive unlocksor the app refuses to start
  3. VPN interface gets its addresswaits up to 30 s, never blocks boot
  4. Docker startswith everything it depends on ready
  5. All 16 containers come upno manual restarts
  6. Port check runsat 2 minutes, then every 10 minutes

Incidents, root causes and permanent fixes

These are real incidents from my troubleshooting log. Each one is written up as symptom, diagnosis, root cause, fix, verification and rollback.

Everything was up, but nothing answered

After a reboot, every private hostname stopped working
Problem
After a reboot, none of my private hostnames worked, though direct access still did. The DNS and proxy containers both reported Up (healthy).
Root cause
A boot-order race. Docker started before the VPN interface had its address. The DNS and proxy containers bind to that exact address, so Docker silently failed to publish their ports: running, but deaf. A plain restart doesn't retry the binding; only recreating the container does.
Fix
A small systemd oneshot service that waits for the VPN interface to get an address (at most 30 s, and it fails open so it can never hang boot), plus a drop-in that makes docker.service wait for it.
Result
The VPN address now appears 2 seconds into boot and Docker starts at 4 seconds. Every port binds correctly on every boot.
Verified by reboot test

Downloads failed after every reboot

Containers were looking at an empty folder instead of the media disk
Problem
After a reboot, every new download errored and new media never appeared in the library, even after manual scans.
Root cause
The same family of race, with a different resource. Docker started 58 to 74 seconds before the media hard drive finished mounting, so five containers bind-mounted the empty mountpoint and never saw the real disk.
Fix
A systemd drop-in with RequiresMountsFor=, so Docker starts only after the disk is mounted. The mount itself didn't need to change.
Result
Docker now starts 5 seconds after the disk instead of 74 seconds before it. A real power cut later confirmed it: every container recovered with no restarts and no manual steps.
Verified by reboot test and a real power cut

An internet outage and two power cuts locked everyone out

The server was on, but nobody at home could open anything
Problem
In November 2026 the home internet went down, then the power failed twice. On home Wi-Fi nobody could open any app, even though the server was running.
Root cause
Two of them. First, a design gap: everything was VPN-only, and the VPN needs the internet, so after an offline boot the VPN interface never got its address and Docker couldn't publish anything. Second, a Docker failure mode: after the unclean shutdown, Docker threw away "stale" network sandboxes, and five containers came back Up with no network and no published ports. docker restart didn't fix it.
Fix
Three layers. The 10 web interfaces now also listen on the home network, while DNS, the proxy, the archive and remote desktop stay VPN-only, a deliberate and documented trade-off. The kernel setting ip_nonlocal_bind lets containers bind the VPN address before it exists and start serving the moment it appears. And a self-healing docker-port-heal timer compares each container's configured ports with what is actually published, and recreates any service that has lost them.
Result
Verified both on home Wi-Fi and over the VPN. I also disconnected a container from its network on purpose, and the heal service restored it automatically.
Verified by a deliberate failure test

Malware disguised as media files

Fake downloads that extension filters couldn't catch
Problem
Fake releases started appearing in the automated download pipeline for episodes that hadn't aired yet. They were named correctly but contained Windows executables, malware droppers. The system grabbed them, and I had to clean them up by hand.
Root cause
The pipeline trusted names and file extensions. Nothing looked at what a file actually was.
Fix
Two layers. First, configuration: release filters, higher minimum file sizes per quality, a 2-hour grab delay so genuine releases can win, automatic fail-and-blocklist on executable content, and a download-client rule that never writes executable or script files to disk. Then one slipped through with no file extension at all. So I wrote a queue janitor in Python, standard library only, on a 15-minute systemd timer. It inspects completed downloads at the file-header level (MZ means a Windows executable, even when it's renamed to .mkv), checks that a real video file exists, and removes, blocklists and re-searches junk or stalled items. Real videos are left alone and flagged for me to review, and the janitor does nothing at all if the media disk isn't mounted.
Result
Tested against a bare executable, a folder with only text files and an executable disguised as .mkv. All three were caught, and a real video passed. Fakes no longer block the queue.
Verified against disguised test files

Encryption that can't leak

A problem caught in planning, before it could happen
Problem
Four containers mount the whole media disk. If I had unlocked the encrypted archive inside that path, the decrypted files would have been visible inside all four of them.
Root cause
Where the decrypted view lives matters as much as the encryption itself. I also found a gotcha: changing ownership of a gocryptfs mount root changes the encrypted folder's permissions.
Fix
Only the encrypted data stays on the media path. The decrypted view is mounted somewhere else entirely, with the root locked down and per-folder access below it. The empty mountpoint is immutable, so if unlocking fails, the app refuses to start rather than writing unencrypted data.
Result
From inside the other containers, running as their real users rather than root, the archive is invisible and access is denied.
Verified from inside each container

Private DNS that doesn't break public DNS

Clean private names without shadowing my real website or email
Problem
My private records weren't being served, and I needed internal names under the same domain as my public website and email.
Root cause
Pi-hole v6 silently ignores the classic dnsmasq.d config folder.
Fix
I moved the records into Pi-hole's new native config, set through environment variables in Compose. I chose explicit records over a wildcard, so internal names never shadow public ones, and Tailscale split DNS sends only my domain's lookups to Pi-hole.
Result
Private names resolve only on my devices, and everything else uses each device's normal resolver. One debugging lesson I documented: on Windows, nslookup bypasses the split-DNS rules the browser uses, so it "fails" while everything actually works.
Verified with the right tools, now documented

New media without manual scans

File change notifications are unreliable across Docker bind mounts for hardlinks and atomic moves. The library managers now call Jellyfin's API to rescan the exact path on every import, with real-time monitoring kept as a backup.

Drifting subtitles, fixed at scale

I measured the drift with ffsubsync and ruled out the player. The cause was embedded subtitle tracks that didn't match the files. I scripted Bazarr's API to fetch the best match for all 327 episodes: 327 succeeded, 0 failed. The lesson I wrote down: try the tool's obvious fix before deep diagnosis.

A photo and video library I built for it

A private alternative to Google Photos for my own files. It runs only on my server, with its own AI, deployed as a separate Docker Compose project from Git-tagged releases.

Uploads and viewing

  • Resumable, chunked, parallel uploads (tus) from any device, including folder upload and the phone's share sheet
  • Exact duplicates skipped automatically
  • A custom video player with scrub previews, resume position and A–B loop, plus photo zoom and pan

Local AI, nothing leaves the server

  • Search by description and "more like this" with CLIP ViT-L/14
  • Face detection and grouping with InsightFace: name a group once, and every future match is tagged
  • Near-duplicate finder, scene detection, tag suggestions and a daily recommendations feed
  • Models download from pinned revisions and are sha256-verified

Video and security

  • ffmpeg with VAAPI hardware encoding on the Intel GPU, shared with Jellyfin, with automatic CPU fallback
  • PIN login hashed with argon2, lockout and rate limiting, httpOnly sessions and auto-lock
  • Served over HTTPS with a valid certificate through Tailscale Serve, so it installs as an app

How I ship it

  • Before each release: a consistent SQLite backup, the previous source kept for one-step rollback, migrations, then a health check on all three access paths
  • A nightly database backup timer
  • The build fails if any ML import breaks
tagged releases, v0.1.0 to v0.5.0
5
backend tests (pytest)
41
per image analysed, on CPU
~0.6 s
CPU when idle (63 MB RAM)
0.2%
Python 3.12FastAPISQLite (WAL)ONNX RuntimeCLIPInsightFaceffmpeg and VAAPIReact 19TypeScriptViteTanStack QueryPWADockergocryptfs

What it runs on

OS and platform

  • Ubuntu Server 26.04 LTS
  • Docker Engine 29 and Compose v5, bind mounts only
  • systemd services, timers, drop-ins and mount units

Networking and security

  • Tailscale mesh VPN, the only way in
  • Tailscale split DNS and Pi-hole v6
  • Nginx Proxy Manager, routing by hostname
  • gocryptfs encryption that fails closed
  • Ports bound to specific interfaces, never 0.0.0.0

Services

  • Jellyfin with hardware transcoding and 12+ plugins
  • Library management, download automation and Bazarr subtitles
  • Seerr, so the household can request what to watch
  • Copyparty file sharing for camera and drone backups
  • Homarr dashboard and a RustDesk remote-desktop relay

Automation and tooling

  • Bash and Python (standard library) scripts, including the queue janitor
  • 6+ custom systemd services and timers: backups, disk health, janitor, port-heal, boot ordering
  • Git and a private GitHub repo for the docs
  • Obsidian for runbooks and the architecture canvas
  • Claude Code with custom skills, over SSH
Machine
Dell Precision Tower 3420, a workstation repurposed as a server
CPU
Intel Xeon E3-1245 v6, 4 cores and 8 threads at 3.7 GHz
GPU
Intel HD Graphics P630, used for hardware video transcoding
Memory
60 GB RAM, plus 8 GB swap
Storage
512 GB NVMe SSD for the system and app configs, and a 4 TB HDD for media and files
Disk health
Automated weekly SMART self-tests on both drives

How I run it

Documentation as code

The whole homelab is described in a Git-versioned Obsidian vault of 30+ notes: 13 per-service runbooks, an append-only change log, a troubleshooting log, a prioritised risk backlog, an emergency recovery plan, maintenance checklists and an architecture canvas.

Change discipline

Every config edit starts with a timestamped backup and a validation (docker compose config -q). It is applied to one service at a time, verified, and written down with its rollback command.

Backups and health

Nightly config backups briefly stop the stacks for consistent database snapshots, about 20 seconds, and keep 30 archives. The library's database gets its own nightly backup. Secrets are deliberately left out of every backup.

AI-assisted operations, with guardrails

I run the server with Claude Code, an AI agent, over SSH, under an operating policy I wrote. Read-only checks and low-risk changes run directly. Anything touching the firewall, DNS, mounts, volumes, reboots or secrets needs my approval of the exact command. The agent does much of the typing. I designed the system, the guardrails and the workflow, and I own every decision.

My "add a new app" workflow, one of the custom skills I built for the agent:

  1. Understand the app
  2. Read-only pre-check
  3. Written plan
  4. Apply, with backups
  5. Verify the neighbours still work
  6. Document
  7. Commit

Timeline

  1. Server built: Ubuntu and a Docker media stack, a dashboard and file sharing.
  2. Full audit and a documentation vault in Git. Every service locked to VPN-only. Scheduled backups with retention, and weekly disk health tests.
  3. Private domain access with Pi-hole, Nginx Proxy Manager and Tailscale split DNS: clean hostnames, still zero exposure.
  4. Survived the first unplanned power loss with no data loss. Fixed subtitles for 327 episodes through the API.
  5. Found two boot-order race conditions and fixed them permanently with systemd. Automatic library refresh through Jellyfin's API.
  6. A malware-resistant download pipeline, plus my own Python queue janitor that checks file headers, not names.
  7. Self-hosted RustDesk relay. Encrypted storage, and my photo and video library shipped through 5 releases. A real power cut: recovered on its own.
  8. An internet outage and two power cuts led to the home Wi-Fi fallback and the self-healing port service.

What's next

  • HTTPS for every hostnameA wildcard certificate through ACME DNS-01, imported into the reverse proxy. Already designed, rollout pending.
  • Power resilienceA UPS, and power-on after AC loss in the BIOS.
  • 3-2-1 backupsA second disk and an off-site copy.
  • Pinned image versionsInstead of latest.
  • Tighter access controlHost firewall rules and per-device VPN access lists.
  • Monitoring and alertsPush notifications for failed timers, disk health and container restarts.

Ask me about the outage that taught me to design for offline

I'm happy to walk through any of these incidents in more depth, or how I'd run something similar for a team.