Nov 29, 2024 4 min read

Navidrome: The Ultimate Guide to Self-Hosting

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

Navidrome is a lightweight, self-hosted music streaming server that allows you to manage and enjoy your music library from anywhere. As an open-source alternative to proprietary services, it puts you in complete control of your data while offering a sleek, user-friendly interface. In this guide, we’ll walk you through installing, configuring, and managing Navidrome, including setup with Docker or manual installation, reverse proxy configuration, logging, backups, updates, and advanced usage.

Installing Navidrome

πŸ“¦ Docker/Docker Compose Setup

Using Docker is one of the easiest and most efficient ways to deploy Navidrome. Below is a docker-compose.yml file you can use to set up the app.


version: '3.8'

services:

navidrome:

image: navidrome/navidrome:latest

container_name: navidrome

ports:

- 4533:4533 # Exposing the default Navidrome port

volumes:

- ./data:/data # Persistent data storage

- ./music:/music # Folder containing your music library

environment:

- ND_LOGLEVEL=info

- ND_SCANINTERVAL=1h

- ND_SESSIONTIMEOUT=24h

restart: unless-stopped

Run the following commands in the same directory as your docker-compose.yml file:


docker-compose up -d

This command will download the latest Navidrome image, create the required containers, and start the application. Access Navidrome at http://<your-server-ip>:4533.

πŸš€ Manual Installation

For users who prefer manual installation, follow these steps to install Navidrome on a Linux server:

  1. Install dependencies:

sudo apt update

sudo apt install -y wget unzip

  1. Download the latest Navidrome binary:

wget https://github.com/navidrome/navidrome/releases/latest/download/navidrome-linux-amd64.zip

  1. Extract the binary and move it to a global location:

unzip navidrome-linux-amd64.zip

sudo mv navidrome /usr/local/bin/

  1. Create a systemd service for Navidrome:

sudo nano /etc/systemd/system/navidrome.service

Add the following content:


[Unit]

Description=Navidrome Music Server

After=network.target

[Service]

ExecStart=/usr/local/bin/navidrome

Restart=always

User=navidrome

Group=navidrome

WorkingDirectory=/var/lib/navidrome

Environment="ND_LOGLEVEL=info" "ND_SCANINTERVAL=1h"

[Install]

WantedBy=multi-user.target

  1. Reload systemd and start the service:

sudo systemctl daemon-reload

sudo systemctl start navidrome

sudo systemctl enable navidrome

Access Navidrome at http://<your-server-ip>:4533.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To serve Navidrome through a custom domain and make it accessible via HTTPS, set up Nginx as a reverse proxy.

  1. Install Nginx:

sudo apt install -y nginx

  1. Create a new server block for your domain:

sudo nano /etc/nginx/sites-available/navidrome

Add the following configuration:


server {

listen 80;

server_name yourdomain.com;

location / {

proxy_pass http://localhost:4533;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

  1. Enable the configuration and restart Nginx:

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

sudo nginx -t

sudo systemctl restart nginx

πŸ”’ SSL/TLS Setup

Secure your Navidrome instance with Let's Encrypt SSL certificates.

  1. Install Certbot:

sudo apt install -y certbot python3-certbot-nginx

  1. Obtain and apply an SSL certificate:

sudo certbot --nginx -d yourdomain.com

  1. Test automatic renewal:

sudo certbot renew --dry-run

πŸ› οΈ Testing and Reloading Nginx

Check for syntax errors and reload Nginx after any changes:


sudo nginx -t

sudo systemctl reload nginx

Logging and Debugging Navidrome

πŸ—ƒοΈ Enabling Debug Logs

For detailed debugging, enable debug-level logging in Navidrome. Add the following to your environment variables:


ND_LOGLEVEL=debug

Then restart the Navidrome service:


sudo systemctl restart navidrome

πŸ“„ Viewing Logs

Access logs depending on your installation method:

  • Docker:

docker logs navidrome

  • Systemd:

journalctl -u navidrome -f

πŸ› οΈ Troubleshooting Common Issues

If Navidrome is not starting or behaving as expected:

  1. Check for port conflicts:

sudo netstat -tuln | grep 4533

  1. Ensure correct permissions for volumes:

sudo chown -R navidrome:navidrome /var/lib/navidrome

πŸ“€ Exporting Logs

Send logs to an external system for advanced analysis using tools like Fluentd or Filebeat. Example for Filebeat:


sudo filebeat setup --input-type log --path /var/lib/navidrome/logs/

sudo systemctl start filebeat

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup Navidrome’s configuration and music library:


tar -czvf navidrome-backup.tar.gz /var/lib/navidrome /music

πŸ”„ Database Backups

If you use an external database, export it:


mysqldump -u username -p navidrome > navidrome_db_backup.sql

πŸ“… Automated Backup Scripts

Set up a cron job for periodic backups:


crontab -e

Add the following line for daily backups:


0 2 * * * tar -czvf ~/navidrome-backup-$(date +\%F).tar.gz /var/lib/navidrome /music

Updating and Upgrading Navidrome

⬆️ Updating Docker Images

Update to the latest Navidrome image:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

Download and replace the latest binary:


wget https://github.com/navidrome/navidrome/releases/latest/download/navidrome-linux-amd64.zip

unzip -o navidrome-linux-amd64.zip -d /usr/local/bin/

sudo systemctl restart navidrome

πŸ” Checking for Updates

Check the latest release on the Navidrome GitHub page.

Leveraging Navidrome’s Unique Features

πŸ”§ Enabling APIs

Enable Navidrome’s REST API for integrating with external apps by confirming the API is accessible at:


curl http://<your-server-ip>:4533/api

Use the API with tools like Python:


import requests

response = requests.get('http://<your-server-ip>:4533/api')

print(response.json())

🌟 Advanced Configurations

Customize Navidrome further by editing the configuration file at /var/lib/navidrome/navidrome.toml. Example:


BaseURL = "/music"

ScanInterval = "30m"

SessionTimeout = "48h"

Restart the service to apply changes:


sudo systemctl restart navidrome

Wrapping Up

Navidrome empowers you to stream and manage your music library with complete control over your data. From installing and securing your server to enabling APIs and customizing features, the steps in this guide provide everything you need to set up and optimize Navidrome. Start implementing these examples today and enjoy the full benefits of this powerful self-hosted music 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.