The first time I cancelled Netflix and tried to watch my own ripped movies on a hotel TV, nothing played. The file was H.265 10-bit in MKV. The TV didn't support it. The browser transcoder choked. My "save $20 a month" project turned into a weekend of reading about hardware transcoding, and that's the moment you realize media streaming is genuinely hard. This article is the guide I wish I'd had then.
Plex and Jellyfin both solve the same problem-your media library, served to your devices, with metadata, posters, and a Netflix-like UI. Plex is the polished commercial product with a paywall on the good features. Jellyfin is the AGPL-licensed fork of Emby that doesn't phone home and doesn't ask for a credit card. Most developers I know end up running both for a few weeks and picking a side. I'll show you how to run either (or both) on real hardware, with real transcoding, behind a real reverse proxy, reachable from anywhere.
Plex vs Jellyfin: An Honest Comparison
Both projects are mature, both play every common format, both support hardware transcoding. The differences are about philosophy and friction.
| Feature | Plex | Jellyfin |
|---|---|---|
| License | Proprietary server, free tier | AGPLv3, fully free |
| Mobile apps | Free, premium for download | One-time $5 per platform, free F-Droid |
| Hardware transcoding | Plex Pass ($120 lifetime) | Free |
| Music lyrics, trailers, skip intros | Plex Pass | Free |
| Account requirement | Yes, Plex account on server | No, fully self-contained |
| Metadata agents | Excellent (commercial) | Good (TMDB/TVDB/OMDB) |
| Client ecosystem | Huge (every Smart TV, console) | Smaller, growing |
| Phone-home behavior | Servers contact Plex for auth | None |
| Docker image | plexinc/pms-docker |
jellyfin/jellyfin |
I run Jellyfin in production. I run Plex on a second box for family members whose Smart TVs don't have a Jellyfin app. If your household is mostly Apple TV, Plex is still the safer bet. If everyone's on Roku/Fire Stick/web, Jellyfin is fine and you'll save the Plex Pass fee.
Prerequisites
- A machine that stays on. NUC, mini-PC, repurposed desktop, or a small home server. Raspberry Pi 4/5 works for direct play only-don't expect it to transcode 4K.
- A CPU with an integrated GPU, ideally Intel 8th gen or newer (UHD 630+ has full Quick Sync Video with HEVC and AV1 decode on newer chips). If you're serious, an NVIDIA GPU works too but draws more idle power.
- Storage. A single 4TB drive is fine to start. Real homelabs end up with 4+ drives pooled with mergerfs and protected with SnapRAID.
- Docker and Docker Compose installed.
- A domain you control, or willingness to use Tailscale for remote access.
- Patience. Library scanning alone will burn an evening.
Architecture Overview
A typical self-hosted media stack looks like this:
CodeCopy
┌──────────────────────────┐
│ Internet / Tailscale │
└────────────┬─────────────┘
│ HTTPS
▼
┌──────────────────────────┐
│ Caddy reverse proxy │
│ (auto TLS via ACME) │
└────────────┬─────────────┘
│
┌──────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┌────────────┐ ┌──────────────┐ ┌──────────────┐
│ Jellyfin │ │ Plex │ │ *arr stack │
│ (Docker) │ │ (Docker) │ │ (Radarr / │
│ │ │ │ │ Sonarr / │
│ /dev/dri │ │ /dev/dri │ │ Prowlarr) │
│ render │ │ render │ │ │
└─────┬──────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
▼ ▼ ▼
┌──────────────────────────────────────────────────┐
│ /mnt/media ← mergerfs( /mnt/disk{1..N} ) │
│ │
│ SnapRAID parity: /mnt/parity (1 disk) │
└──────────────────────────────────────────────────┘
The key design decisions are: services in Docker, all media mounted read-only inside containers, hardware acceleration passed through /dev/dri, and one reverse proxy handling TLS for everything.
Folder Structure
Keep the host layout boring and predictable. Every service gets a config dir under /opt, every persistent dataset under /mnt.
Plain TextCopy
plaintext
/opt/jellyfin/ # config, metadata cache, transcode dir
/opt/plex/
/opt/caddy/Caddyfile
/mnt/disk1/ # individual data disks, mounted at boot
/mnt/disk2/
/mnt/parity/ # SnapRAID parity
/mnt/media # mergerfs view of disk1..N
├── movies/
├── tv/
├── music/
└── photos/
markdown
/mnt/media is the only path the containers see. If you ever migrate disks or rebuild the pool, the container mounts don't change.
Storage: mergerfs + SnapRAID
A single big disk is the easy path until it dies. RAID 5 rebuilds are stressful on modern high-capacity drives and the array is slow while it runs. The homelab consensus is mergerfs (file-level concatenation, no striping) plus SnapRAID (snapshot parity, run nightly).
Install both:
BashCopy
shell
sudo apt install mergerfs snapraid
conf
/etc/fstab:
Plain TextCopy
conf
/dev/disk/by-id/ata-WDC_WD40EFRX-1 /mnt/disk1 ext4 defaults,noatime 0 2
/dev/disk/by-id/ata-WDC_WD40EFRX-2 /mnt/disk2 ext4 defaults,noatime 0 2
/dev/disk/by-id/ata-WDC_WD40EFRX-3 /mnt/parity ext4 defaults,noatime 0 2
/mnt/disk1:/mnt/disk2 /mnt/media fuse.mergerfs \
defaults,allow_other,category.create=mfs,moveonenospc=true,dropcacheonrename=true 0 0
conf
/etc/snapraid.conf:
Plain TextCopy
conf
parity /mnt/parity/snapraid.parity
content /mnt/disk1/snapraid.content
content /mnt/disk2/snapraid.content
content /opt/snapraid/snapraid.content
data d1 /mnt/disk1/
data d2 /mnt/disk2/
exclude *.unrecoverable
exclude /tmp/
exclude /lost+found/
exclude *.!sync
exclude *.bak
plaintext
A nightly sync + scrub cron:
BashCopy
shell
!/usr/bin/env bash
/opt/snapraid/nightly.sh
set -euo pipefail
LOG=/var/log/snapraid.log
{
echo "=== $(date) ==="
snapraid sync
snapraid scrub -p 8 -o 1
} >> "$LOG" 2>&1
markdown
Crucially: mergerfs is not RAID. If a disk dies before SnapRAID has run, the files written since the last sync are gone. SnapRAID is snapshot parity, not real-time. This is the trade-off. For movies you can re-rip, that's fine. For irreplaceable photos, back them up off-site too.
Hardware Transcoding: The Part That Always Bites
Direct play is when the client can decode the file as-is. Transcoding is when the server has to convert it on the fly. 4K HEVC to 1080p H.264 in software will pin 8 cores and deliver 4 FPS. The fix is hardware: pass /dev/dri into the container and let the iGPU do it.
Verify the iGPU is present:
BashCopy
shell
ls -l /dev/dri
crw-rw---- 1 root render 226, 0 Nov 12 10:00 card0
crw-rw---- 1 root render 226, 128 Nov 12 10:00 renderD128
vainfo 2>&1 | head -20
plaintext
vainfo should list VAProfileHEVCMain10 and VAProfileVP9Profile0. If you don't have it, install intel-media-va-driver-non-free on Debian/Ubuntu.
Add your media user to the render group so the container can access the device:
BashCopy
shell
sudo usermod -aG render jellyfin
sudo usermod -aG render plex
markdown
The classical symptom of "transcoding doesn't work" is the server going to 100% CPU and the video pausing every few seconds. That's software transcoding. The container is missing /dev/dri or the render group permission.
Docker Compose for Jellyfin
Here's a production-ready compose file. Note the /dev/dri device, the render group ID mapped via group_add, and the explicit no-new-privileges security option.
YAMLCopy
yaml
/opt/jellyfin/docker-compose.yml
services:
jellyfin:
image: jellyfin/jellyfin:10.9.11
container_name: jellyfin
restart: unless-stopped
user: "1000:1000"
group_add:
- "109" # the GID of
renderon this host, check withgetent group renderdevices: - /dev/dri/renderD128:/dev/dri/renderD128
- /dev/dri/card0:/dev/dri/card0 volumes:
- ./config:/config
- ./cache:/cache
- /mnt/media:/media:ro environment:
- TZ=America/Chicago
- JELLYFIN_PublishedServerUrl=https://jellyfin.example.com
- JELLYFIN_CONFIG_DIR=/config ports:
- "127.0.0.1:8096:8096" # only the reverse proxy talks to this security_opt:
- no-new-privileges:true mem_limit: 4g healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8096/health"] interval: 30s timeout: 5s retries: 3
plaintext
Inside Jellyfin, enable VAAPI under Dashboard → Playback → Transcoding. Pick /dev/dri/renderD128 as the device. Test with a 4K HEVC file forced to 1080p max and a 20 Mbps bitrate cap-CPU should stay under 10%.
Docker Compose for Plex
Plex is similar but the image expects a claim token from plex.tv on first boot.
YAMLCopy
yaml
/opt/plex/docker-compose.yml
services:
plex:
image: plexinc/pms-docker:latest
container_name: plex
restart: unless-stopped
hostname: plex
devices:
- /dev/dri/renderD128:/dev/dri/renderD128
- /dev/dri/card0:/dev/dri/card0 volumes:
- ./config:/config
- ./transcode:/transcode
- /mnt/media:/data:ro environment:
- TZ=America/Chicago
- PLEX_CLAIM=claim-XXXXXXXXXXXXXXXX # from https://www.plex.tv/claim/
- PLEX_ADVERTISE_URL=http://127.0.0.1:32400
- PLEX_NO_AUTH_NETWORKS=10.0.0.0/8 network_mode: host # Plex uses many ports, host is simpler security_opt:
- no-new-privileges:true
markdown
Plex Pass is required for hardware transcoding. Without it, you'll see "Transcoding (cpu)" in the dashboard and CPU will spike. Don't waste a weekend debugging the /dev/dri perms if you haven't bought Plex Pass yet-it's gated behind the feature flag.
Plex uses network_mode: host because it broadcasts on multiple ports (32400 main, 32469 DLNA, 1900/5353 UDP for discovery). You can run bridge mode with explicit port mappings, but DLNA auto-discovery will break for clients that rely on it.
Reverse Proxy with Caddy
You want HTTPS for remote access and you want a single port forwarded. Caddy is the lowest-friction option because ACME is built in.
Plain TextCopy
conf
/opt/caddy/Caddyfile
jellyfin.example.com {
reverse_proxy 127.0.0.1:8096 {
flush_interval -1
}
encode zstd gzip
# Jellyfin's recommended headers
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Frame-Options SAMEORIGIN
X-Content-Type-Options nosniff
Referrer-Policy no-referrer
# don't apply Caddy's default CSP, Jellyfin sets its own
?Content-Security-Policy ""
}
@websockets {
header Connection Upgrade
header Upgrade websocket
}
reverse_proxy @websockets 127.0.0.1:8096
}
plex.example.com {
reverse_proxy 127.0.0.1:32400
encode zstd gzip
}
plaintext
The flush_interval -1 is critical for Jellyfin-it disables buffering so streaming chunks reach the client immediately. Without it, you'll see 30-second startup stalls on every video.
Run Caddy in Docker too:
YAMLCopy
yaml
/opt/caddy/docker-compose.yml
services:
caddy:
image: caddy:2.8-alpine
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp" # HTTP/3 volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- ./data:/data
- ./config:/config network_mode: host # so Caddy can reach 127.0.0.1:8096 on the host security_opt:
- no-new-privileges:true
markdown
If you'd rather not open ports on your router, skip this whole section and use Tailscale.
Remote Access: Tailscale vs Cloudflare Tunnel vs Port Forward
| Approach | Setup | Latency | Bandwidth | Egress IP |
|---|---|---|---|---|
| Port forward + ACME | Caddy handles TLS | Best (direct) | Your home upload | Your home IP |
| Tailscale |
tailscale up on server, install on clients |
WireGuard direct or DERP relay | WireGuard limit, decent | NAT traversal |
| Cloudflare Tunnel |
cloudflared outbound only |
+1 hop through CF | CF ToS restricts streaming | CF IPs |
| Tailscale Funnel | Public HTTPS via Tailscale | Routed through DERP | Limited by relay | Tailscale |
Cloudflare Tunnel's free ToS technically excludes "large file streaming." People do it anyway and most accounts never get flagged, but if you care about the letter of the agreement, don't. Use Tailscale for family-if they can install a phone app, they can use Tailscale. Use port forwarding + Caddy for yourself.
Tailscale setup:
BashCopy
shell
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up --advertise-tags=tag:media
markdown
On each client device, install Tailscale, log into the same tailnet, and you're done. The Jellyfin URL becomes http://jellyfin-server:8096 from anywhere on the tailnet. No TLS, no port forwarding, no DNS.
Library Structure That Won't Bite You
Both Plex and Jellyfin have hard opinions about file layout. Get this wrong and metadata matching turns into a part-time job.
Plain TextCopy
plaintext
/mnt/media/movies/
The Matrix (1999)/
The Matrix (1999) [1080p] [Bluray].mkv
The Matrix Reloaded (2003)/
The Matrix Reloaded (2003) [1080p] [Bluray].mkv
/mnt/media/tv/
Breaking Bad (2008)/
Season 01/
Breaking Bad - S01E01 - Pilot.mkv
Breaking Bad - S01E02 - Cat's in the Bag.mkv
/mnt/media/music/
Artist/
Album (Year)/
01 - Track.flac
markdown
The patterns the metadata agents look for:
- Movies:
<Title> (<Year>)folder,<Title> (<Year>) [<Quality>].extfile - TV:
<Show Name> (<Year>)/Season XX/withSxxExxin the filename - Anime: same as TV but use the absolute episode number too if your agent supports it
Avoid subfolders with extras, posters, behind-the-scenes mixed in. Put those in a separate Extras/ folder inside the movie folder-Jellyfin and Plex both special-case it.
Permissions: The Recurring Headache
Docker containers run as whatever UID/GID you tell them. If the host files are owned by 1000:1000 and you let the container run as root, you'll end up with files owned by root that you can't delete from the host later. Worse, if Jellyfin can't write to its config dir, the wizard silently fails.
Pick a UID/GID and stick with it across every service. Mine is 1000:1000.
BashCopy
shell
sudo chown -R 1000:1000 /opt/jellyfin /opt/plex /mnt/media
sudo chmod -R 775 /opt/jellyfin /opt/plex
sudo find /mnt/media -type d -exec chmod 775 {} \;
sudo find /mnt/media -type f -exec chmod 664 {} \;
plaintext
The render group needs to be the same GID inside and outside the container. Check on the host:
BashCopy
plaintext
getent group render
render❌109:jellyfin,plex
markdown
Then in compose, group_add: ["109"] makes the container's process a member of that group. If the GID on the host is different (some distros use 44), change the number.
Monitoring: Know Before Your Family Complains
Prometheus node_exporter for the host, plus Jellyfin's built-in webhook for play events. The minimum useful dashboard tracks:
- CPU per-core utilization (sustained 100% on one core = transcoding)
- Memory (Jellyfin metadata scans are hungry)
- Disk I/O per device (parity checks spike disk reads)
- Disk temperature (
hddtemporsmartctl) - Network throughput per interface
A minimal docker-compose.monitoring.yml:
YAMLCopy
yaml
services:
node_exporter:
image: prom/node-exporter:v1.8.2
container_name: node_exporter
restart: unless-stopped
pid: host
volumes:
- /:/host:ro,rslave
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /dev:/host/dev:ro command:
- --path.rootfs=/host
- --collector.diskstats
- --collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+)($|/) network_mode: host
markdown
Pair with Grafana and a SMART exporter (smartctl-exporter) and you'll know a drive is failing before it dies. Don't skip this-nothing is worse than explaining to your partner why all the movies vanished on movie night.
Common Mistakes
Running as root in the container. Symptom: files created on the host array are owned by root and you can't rm them without sudo. Fix: set user: in compose, chown the host directories to match.
Forgetting the render group on the device. Symptom: Jellyfin says "VAAPI init failed" or silently falls back to software. Fix: group_add: ["<gid>"] and ls -l /dev/dri shows the group can read renderD128.
Exposing Jellyfin directly to the internet without HTTPS. Symptom: login page on HTTP, your password goes in cleartext. Fix: Caddy + ACME, or Tailscale.
Mounting media read-write. Symptom: Jellyfin happily renames your carefully named files based on a bad metadata match. Fix: :ro on the mount. Use a separate /incoming volume if Jellyfin needs to write.
Putting the transcode cache on a spinning disk. Symptom: seeking is slow, transcoding stalls. Fix: transcode to /config/transcode on an SSD, or mount tmpfs.
Trusting one disk with no parity. Symptom: drive dies, library is gone. Fix: SnapRAID parity, plus off-site backup of anything irreplaceable.
Forgetting to update TLS SAN when changing hostname. Symptom: mobile app refuses to connect after a hostname change. Fix: regenerate cert, or use a wildcard.
Troubleshooting with Real Production Examples
"Videos buffer every 10 seconds." Open the Jellyfin dashboard while playing. If you see "Direct playing," the network is the bottleneck-your home upload or the client's download. If you see "Transcoding (cpu)," hardware accel isn't working. Check vainfo inside the container:
BashCopy
shell
docker exec -it jellyfin vainfo
plaintext
If vainfo doesn't list HEVC, the wrong driver is loaded. On Intel 12th gen+, you need intel-media-va-driver-non-free (Debian) or intel-media-va-driver (newer versions support all features).
"Plex remote access says 'not available outside your network.'" Plex's relay service uses a stun-style NAT check. If it can't reach plex.tv:32400 from inside, it won't publish. Check docker logs plex | grep -i relay and confirm outbound 32400/TCP works. Sometimes you need to set PLEX_ADVERTISE_URL to your public hostname explicitly.
"Music won't scan, every album shows as unknown." The metadata agent is probably set to TheAudioDB but your folder layout is wrong. Music agents are extremely picky: <Artist>/<Album> (<Year>)/NN - <Track>.ext. Check Media Info on a single track-if Album and Artist tags are missing from the file itself, fix the tags with beet or MusicBrainz Picard before rescanning.
"Library scan is at 1% after an hour." Either the disk is slow (check iostat -x 1) or you've pointed Jellyfin at the wrong directory and it's walking the entire filesystem. docker exec jellyfin find /media -type f | wc -l should match what you expect. If it's millions of files, you've mounted something you didn't mean to.
"Subtitles don't show." Most clients only support SRT for direct play. PGS or ASS subs force a transcode. Convert with ffmpeg -i input.mkv -map 0:s:0 -c:s srt output.en.srt and put the SRT next to the video.
Best Practices
- Use a dedicated user for media services, never root.
- Pin image versions (
jellyfin/jellyfin:10.9.11, notlatest). Tag updates break things; you want to read release notes before upgrading. - Schedule library scans nightly, not on file change. Inotify scans thrash on huge libraries.
- Keep one off-site backup of
/opt/jellyfin/configand/opt/plex/config. Rebuilding metadata for 5,000 movies takes a week. - Test your restore. An untested backup is a hope, not a backup.
- Set
restart: unless-stoppedand watch logs after every reboot. - Forward
:443only, never:80if you can avoid it. Caddy handles the redirect. - Use Tailscale ACLs to restrict who can reach the media box. Family doesn't need SSH access.
CI/CD and Updates
A justfile or Makefile for routine ops:
makefileCopy
make
Makefile
.PHONY: update backup
update:
docker compose -f /opt/jellyfin/docker-compose.yml pull
docker compose -f /opt/jellyfin/docker-compose.yml up -d
docker image prune -f
backup:
tar czf /mnt/parity/backups/jellyfin-config-$(date +%F).tgz /opt/jellyfin/config
rsync -a /mnt/parity/backups/ user@offsite:/backups/jellyfin/
find /mnt/parity/backups -name 'jellyfin-config-*.tgz' -mtime +30 -delete
plaintext
Cron weekly:
cronCopy
shell
0 3 * * 0 root make -C /opt update && make -C /opt backup
plaintext
For major version upgrades (Plex, Jellyfin), snapshot the config volume first. With ZFS:
BashCopy
shell
zfs snapshot tank/jellyfin-config@pre-$(date +%F)
plaintext
With LVM:
BashCopy
shell
lvcreate -s -L 5G -n jellyfin-snap /dev/vg0/jellyfin
If the upgrade breaks something, revert the snapshot. Without a snapshot, you're restoring from tarball and praying the database schema is compatible.
Cost Considerations
A real breakdown for a 4-disk NUC-based server:
| Component | One-time | Notes |
|---|---|---|
| Intel NUC 13 (i5, 16GB, 500GB NVMe) | $500 | Includes Quick Sync |
| 4 × 18TB WD Red Plus | $1,400 | Watch for sales |
| UGREEN 4-bay USB enclosure | $250 | Or build a real NAS |
| UPS (CyberPower 1500VA) | $200 | Don't skip this |
| Domain | $12/yr | For Caddy ACME |
| Tailscale | $0 | Personal tier is free |
| Plex Pass | $120 once | Lifetime, if you go Plex |
| Total | ~$2,500 | Replaces ~$25/mo streaming |
Power draw is the recurring cost. A NUC + 4 spinning disks idle around 35W. At $0.15/kWh, that's about $46/year. You're not saving money in year one. You're saving money in year three, and you own the library.
Real-World Use Cases
Family with mixed devices. I run Jellyfin as the primary, Plex for the one Smart TV that doesn't have a Jellyfin app. Same media mount, two services, no duplication.
University dorm media share. A friend runs Jellyfin for his floor with Tailscale ACLs. Each student gets an account, watch history is per-user, and the admin can see who's hammering the transcoder at 2 AM.
Photo backup with auto-tagging. Jellyfin has an image library mode that auto-tags faces using a local ML model. Mount /mnt/media/photos, enable the plugin, let it run overnight. It's not Google Photos, but the photos never leave your network.
Personal music streaming. Jellyfin has a competent music player and integrates with Finamp on mobile. The audio quality beats Spotify's free tier because you control the source files.
Conclusion
Self-hosting your media is one of the few projects that delivers exactly what it promises: your library, on your hardware, on your terms. The setup is genuinely fiddly the first time-permissions, hardware transcoding, reverse proxy, and remote access all want to bite you. Once it works, it stays working for years. The trade-off is your time and the discipline to keep backups. If you're the kind of developer who reads this site, you'll find the fiddliness rewarding rather than annoying.
Originally published on Mango Developer.
Top comments (0)