Homelab
Docker
DevOps
SystemArchitecture
SelfHosting

The Digital Workshop: Building a Self-Healing, Hybrid-Access Homelab

February 21, 2025
10 min read
Intermediate
The Digital Workshop: Building a Self-Healing, Hybrid-Access Homelab
TL;DR

I turned an old office PC into a resilient application platform using Ubuntu and CasaOS. I implemented a hybrid network strategy (Cloudflare for public UI, Tailscale for admin access) and automated a secure media pipeline, solving critical volume mapping and networking challenges along the way.

Architecture Diagram
Architecture Diagram: Traffic flows from Public Internet and Private Network into the Secure Media Stack.

1. The Context: From "Server" to "Workshop"

The Need

Every engineer goes through a phase where they just want a Linux box to run a script. For years, ssh was enough for me. But as my needs grew—home automation, media streaming, file syncing, AI testing—managing ports and config files via CLI became friction, not a feature.

I didn't just want a server; I wanted a Digital Workshop.

A workshop is messy. You break things. You prototype. You need tools on the wall (Dashboards) and a safety net (Backups). My goal was to build an infrastructure that prioritizes convenience over purity.

1

Foundation

An OS that handles Docker easily on bare metal.
2

Resilience

Automated backups *first*, so I can break things without fear.
3

Access

A way to get in from anywhere without opening dangerous ports.
4

The Stress Test

A concrete, heavy workload (The *Arr Media Stack) to push the architecture to its limits.

2. The Foundation: OS & Hardware

The Hardware: Enterprise Scrap Gold

I started with a Dell Optiplex 3060 SFF.

  • CPU: Intel Core i3-8100 (8th Gen).
  • Why it matters: This CPU includes Intel QuickSync. This is the secret weapon. It allows this humble office PC to transcode multiple 4K video streams in hardware, leaving the CPU idle. It punches way above its weight class.

The OS: Theory & Choice

I considered Proxmox (Hypervisor). It's the industry standard. However, for a single low-power machine, running VMs adds overhead. I wanted bare-metal performance with container isolation.

The Winner: Ubuntu Server 24.04 LTS + CasaOS.

  • Ubuntu: Rock-solid stability.
  • CasaOS: It's not a real OS, but a UI layer for Docker. It visualizes storage, CPU, and ports, acting as the "Dashboard" for my workshop.
CasaOS Dashboard
CasaOS Dashboard: A sleek grid of icons (Home Assistant, Files, Portainer) and system status widgets.

Execution & The "Peripeties"

Bug #1: The 100GB Trap

I installed Ubuntu on a 240GB SSD, but the dashboard showed the drive was full after only 100GB.

  • The Investigation: Running lsblk showed the disk was 240GB, but df -h showed the filesystem was 100GB.
  • The Cause: Ubuntu's default LVM (Logical Volume Manager) installer reserves half the disk space for snapshots/expansion.
  • The Fix: I had to extend the logical volume live:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Bug #2: The Man-in-the-Middle Scare

After a reinstall, SSH refused to connect: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!.

  • The Cause: My laptop remembered the "fingerprint" of the old installation at 192.168.1.5.
  • The Fix:
ssh-keygen -R 192.168.1.5

3. Disaster Recovery: Sleep Insurance

A workshop isn't safe if it burns down. I realized that if my SSD died, I would lose hours of YAML configuration. State is sacred; containers are disposable.

The Solution: Duplicati

I deployed Duplicati to back up the /DATA/AppData folder (where all Docker configs live) to Google Drive, encrypted with AES-256.

Bug #3: The Empty Backup

I ran the first backup. It finished instantly. The file size was 0KB.

  • The Investigation: I opened the Duplicati console: ls -la /source. It was empty.
  • The Cause: In the Docker volume mapping, I mapped /DATA/AppData to /host, but told Duplicati to back up /source.
  • The Fix: Remapped the volumes correctly in CasaOS settings (/DATA/AppData -> /source) and verified the file list via CLI before running the job.
Bug #4: The Start-Up Crash

Duplicati refused to start. Logs showed: *** Missing encryption key ***.

The Fix: Newer versions require a SETTINGS_ENCRYPTION_KEY environment variable. I generated a secure string and added it to the container config.

4. The Access Layer: Public vs. Private

The Need: I need to access Home Assistant from my phone (Public) and Portainer from my laptop (Private), without opening ports on my router.

The Strategy

  • Public (Cloudflare Tunnel): For "App-like" usage. Maps https://ha.mydomain.com → localhost:8123.
  • Private (Tailscale): For "Root-like" usage. Creates a mesh VPN where I can access raw ports 192.168.1.5:9000 securely.

Execution & The "Peripeties"

Bug #5: The '400 Bad Request' Loop

I set up the tunnel, visited ha.mydomain.com, and got a white screen saying "400 Bad Request".

  • The Theory: Home Assistant blocks requests from reverse proxies (like Cloudflare) by default for security.
  • The Attempt: I edited configuration.yaml in CasaOS to add the trusted proxies. I restarted HA. Nothing happened.
  • The Deep Dive (Sherlock Moment): I realized CasaOS offers two versions of Home Assistant. I was editing a Ghost File. The running container was mapped to /DATA/AppData/big-bear-homeassistant.
  • The Fix: I located the correct volume path via Portainer, edited the real file, and added the specific docker bridge network:
configuration.yaml
http:
use_x_forwarded_for: true
trusted_proxies:
  - 172.16.0.0/12  # Covers Docker subnet
  - 127.0.0.1      # Localhost (Tunnel endpoint)

5. The Workload: The "Fort Knox" Media Stack

The Goal: Automate media acquisition (Sonarr/Radarr) and playback (Jellyfin) while ensuring Zero IP Leaks for the torrent client and total privacy for the searchers.

The Architecture: "The Sidecar"

I didn't want to use a system-wide VPN (which would break remote access). I used the Docker Sidecar Pattern via a Portainer Stack.

1

The Gateway

Gluetun. This container establishes a WireGuard connection to Mullvad VPN.
2

The Protected Pack

qBittorrent, Sonarr, Radarr, Prowlarr, and Flaresolverr. Config: `network_mode: service:gluetun`. These containers lose their own network interfaces and route ALL traffic through Gluetun.
3

The Helper

Flaresolverr. Solves Cloudflare CAPTCHAs so Prowlarr can index seamlessly.

Execution & The "Peripeties"

Bug #6: The IPv6 Crash

Gluetun refused to start. Logs showed: IPv6 is not supported.

The Cause: I blindly copied the WireGuard config from Mullvad, which included an IPv6 address. Docker networking often struggles with IPv6 inside containers.

The Fix: Removed the IPv6 address from the compose file.

Bug #7: The Missing Icons

In CasaOS, my beautiful stack appeared as "Legacy Apps" with grey icons. I tried to "Import" them to fix it, but CasaOS threw an error: conflicting options: hostname and network mode.

The Aha! Moment: CasaOS cannot manage "Sidecar" containers natively because the UI expects every container to have its own network.

The Fix: I had to add specific labels to the Docker Compose file in Portainer to trick CasaOS.

6. Conclusion & The "Cookie Jar"

This project was more than just installing apps; it was an exercise in Linux networking and volume management.

What I gained:

  • A "God Mode" VPN: Tailscale lets me manage my server from my phone as if I'm on the LAN.
  • A Netflix-like experience: Jellyseerr + *Arr stack handles all media requests automatically.
  • Peace of Mind: If the server burns down, I reinstall Linux, install Duplicati, restore one folder, and I'm back.

Next Steps:

  • Adding LLM Inference (Ollama) to utilize the CPU.
  • Integrating Voice Control (Wyoming/Piper) into Home Assistant.

The workshop is open for business.

Written by Ayman Ben Hajjaj

Data Engineer & Project Manager