Jellyfin Proxy
Running a Jellyfin Proxy with NixOS, a Raspberry Pi, and Tailscale
Problem
I want to access my Jellyfin server from anywhere. Here is how I achieved this using NixOS, a Raspberry Pi (RPi), and Tailscale.
Background
At home, I run a NAS with Jellyfin to watch my own media. Previously, I had used Plex, but I decided to make the change to Jellyfin after a few frustrations.
Plex had a service for easily connecting to your home server from anywhere called “Plex Remote Access,” which I often used while traveling and was a must-have for my Jellyfin setup.
This was also an opportune time to harden the security of my NAS. Instead of opening my server to the world, I wanted to use Wireguard as the only remote access to my NAS.
Tailscale seemed like a great fit, as I had already replaced Synology’s QuickConnect service with Tailscale + nginx.
Setting up the Raspberry Pi (RPi)
After ordering an RPi Model 4 B, I decided to run NixOS instead of Raspbian. I use an RPi because they are relatively inexpensive and easy to work with. Eventually, I’d like to find a smaller device or microcontroller for this project, but this serves as a great start.
I chose NixOS because:
- I run NixOS on my desktop and laptop, so I can share a base config across my devices.
- The Raspberry Pi is replaceable and scalable. Replacement is as easy as flashing a new SD card.
- All of the device is defined as code.
- I can track changes in source control!
- The contents on the RPi are discoverable.
- In a low-touch project like this, it’s hard to remember the changes I make, so a mutable system would lead to natural drift.
Defining the RPi NixOS Flake
I extended my existing NixOS flake to include a definition for the RPi that will run my Jellyfin proxy.
rpi = nixpkgs.lib.nixosSystem {
system = "aarch64-linux"; # RPi is a 64-bit ARM system
specialArgs = {
hostname = "rpi"; # Pass the host name to rpi.nix. This lets us create multiple RPi proxy devices.
};
modules = [
./systems/rpi/rpi.nix # RPi specific configurations.
..
];
};
You can find the complete flake on my GitHub.
RPi Nix Config
With the RPi added as a target to the flake, I defined the RPi config. Here are the highlights:
# Define a nginx service to forward Jellyfin traffic to NAS.
# This allows other devices to connect to Jellyfin via the RPi.
services.nginx = {
enable = true;
recommendedProxySettings = true;
virtualHosts."jellyfin" = {
listen = [
{
addr = "0.0.0.0";
port = 8096;
}
];
locations."/" = {
# This is the tailnet IP address of my Jellyfin server.
proxyPass = "http://100.113.49.85:8096";
proxyWebsockets = true;
};
};
};
# Add tailscale service so RPi can connect to NAS from anywhere.
# Don't forget to add the RPi to your tailnet!
services.tailscale.enable = true;
# Allow other devices to connect to the Jellyfin port
networking.firewall = {
enable = true;
allowedTCPPorts = [
8096 # Jellyfin port
];
};
You can find the complete config on my GitHub.
Conclusion
Success! I have an easy way to bridge Jellyfin to any remote network. I have successfully run this setup in multiple locations. It’s as simple as looking up the local IP address of the RPi and pointing any Jellyfin client to it.
In the future, I would like to use HTTPS for this port and further harden the Tailscale connection, but I am happy with the result!