Nov 29, 2024 3 min read

Jellyfin: The Ultimate Guide to Self-Hosting

Jellyfin: The Ultimate Guide to Self-Hosting
Table of Contents

Jellyfin is a powerful, open-source media server designed for self-hosting. It enables users to centralize and stream their media libraries while retaining complete control over their data. Unlike commercial solutions, Jellyfin offers unlimited customization and freedom from licensing restrictions. This guide provides hands-on steps to install, configure, and manage Jellyfin, covering everything from reverse proxies to backups and updates.

Installing Jellyfin

πŸ“¦ Docker/Docker Compose Setup

Using Docker simplifies Jellyfin’s deployment and management. Below is a docker-compose.yml file to set up Jellyfin with proper volume mappings for persistent storage and port configurations.


version: '3.8'

services:

jellyfin:

container_name: jellyfin

image: jellyfin/jellyfin:latest

restart: unless-stopped

ports:

- "8096:8096" # Web interface and streaming

- "8920:8920" # Optional: HTTPS traffic

volumes:

- ./config:/config      # Configuration data

- ./cache:/cache        # Cache directory

- /path/to/media:/media # Media library

environment:

- TZ=America/New_York   # Set your timezone

Run the following commands to deploy Jellyfin:


mkdir jellyfin && cd jellyfin

nano docker-compose.yml  # Paste the above content into this file

docker-compose up -d     # Start Jellyfin in detached mode

Access Jellyfin via http://<your-server-ip>:8096.

πŸš€ Manual Installation

For a direct installation on a Linux server, follow these steps:

  1. Add the Jellyfin repository and install required packages:

sudo apt update

sudo apt install apt-transport-https gnupg

wget -O - https://repo.jellyfin.org/debian/jellyfin_team.gpg.key | sudo tee /usr/share/keyrings/jellyfin.gpg > /dev/null

echo "deb [signed-by=/usr/share/keyrings/jellyfin.gpg] https://repo.jellyfin.org/debian bullseye main" | sudo tee /etc/apt/sources.list.d/jellyfin.list

sudo apt update

sudo apt install jellyfin

  1. Start the Jellyfin service:

sudo systemctl start jellyfin

sudo systemctl enable jellyfin

Access Jellyfin via http://<your-server-ip>:8096.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

Set up an Nginx server block to route traffic to Jellyfin. This configuration assumes Jellyfin is running on http://localhost:8096.


server {

listen 80;

server_name yourdomain.com;

location / {

proxy_pass http://localhost:8096;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

}

}

Save this file as /etc/nginx/sites-available/jellyfin and create a symbolic link:


sudo ln -s /etc/nginx/sites-available/jellyfin /etc/nginx/sites-enabled/

sudo nginx -t  # Test the configuration

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your Jellyfin instance with Let's Encrypt:

  1. Install Certbot:

sudo apt install certbot python3-certbot-nginx

  1. Generate and apply SSL certificates:

sudo certbot --nginx -d yourdomain.com

  1. Automate certificate renewals:

sudo systemctl enable certbot.timer

πŸ› οΈ Testing and Reloading Nginx

Verify the configuration:


sudo nginx -t

sudo systemctl reload nginx

Visit https://yourdomain.com to access Jellyfin securely.

Logging and Debugging Jellyfin

πŸ—ƒοΈ Enabling Debug Logs

To enable debug logging, modify the Jellyfin configuration file (/etc/jellyfin/system.xml for manual installs):


<LogLevel>Debug</LogLevel>

Restart Jellyfin to apply:


sudo systemctl restart jellyfin

πŸ“„ Viewing Logs

For Docker users:


docker logs -f jellyfin

For manual installations:


tail -f /var/log/jellyfin/server.log

πŸ› οΈ Troubleshooting Common Issues

Look for specific errors in the logs (e.g., missing media files, transcoding failures). Resolve issues by checking file permissions or installing missing dependencies.

πŸ“€ Exporting Logs

Use this command to compress and export logs for external analysis:


tar -czvf jellyfin_logs.tar.gz /var/log/jellyfin/

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup configuration and metadata:


tar -czvf jellyfin_backup.tar.gz /path/to/config /path/to/cache

Restore by extracting:


tar -xzvf jellyfin_backup.tar.gz -C /

πŸ”„ Database Backups

For SQLite-based Jellyfin installations, backup the database:


cp /path/to/config/data/library.db /path/to/backup/

Restore the database:


cp /path/to/backup/library.db /path/to/config/data/

πŸ“… Automated Backup Scripts

Automate backups with a cron job:


crontab -e

0 0 * * * tar -czvf /path/to/backups/jellyfin_$(date +\%F).tar.gz /path/to/config /path/to/cache

Updating and Upgrading Jellyfin

⬆️ Updating Docker Images

Update Jellyfin by pulling the latest Docker image:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, upgrade via the package manager:


sudo apt update

sudo apt upgrade jellyfin

πŸ” Checking for Updates

Check for updates in the Jellyfin web interface under Dashboard > Updates or monitor the official Jellyfin GitHub releases.

Leveraging Jellyfin’s Unique Features

πŸ”§ Enabling APIs

Enable Jellyfin’s APIs for external integrations via Dashboard > API Keys. Use the generated API key for automation:


curl -H "X-Emby-Token: YOUR_API_KEY" http://localhost:8096/emby/Users

🌟 Advanced Configurations

Enable hardware acceleration for transcoding by editing /etc/jellyfin/ffmpeg.json (manual installs) or passing GPU-specific flags in Docker:


devices:

- /dev/dri:/dev/dri

Enable plugins via the Jellyfin web interface under Dashboard > Plugins, such as trakt.tv for media scrobbling.

Wrapping Up

Self-hosting Jellyfin provides an unparalleled level of control and customization for your media streaming needs. By following this guide, you’ve learned how to securely install, configure, and manage your Jellyfin instance while leveraging its unique features. Begin experimenting with the provided examples and enjoy the power of owning your media server!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.