Nov 9, 2024 3 min read

Madsonic: A Complete Checklist for Self-Hosting Success

Madsonic: A Complete Checklist for Self-Hosting Success
Table of Contents

Madsonic is a web-based media server and music streaming application designed for self-hosting. It allows users to organize, stream, and manage their media collections while maintaining full control over their data. With features like multi-user access, transcoding, API support, and customization, Madsonic is an excellent choice for tech-savvy users who want a powerful and flexible media server. This guide covers everything from installation to configuration, logging, updates, and leveraging its unique features.

Installing Madsonic

πŸ“¦ Docker/Docker Compose Setup

Using Docker is the easiest way to host Madsonic. Below is a docker-compose.yml file tailored for Madsonic deployment, along with the necessary commands.


version: '3.8'

services:

madsonic:

image: madsonic/madsonic

container_name: madsonic

ports:

- "4040:4040"  # Main Madsonic interface

volumes:

- ./madsonic_data:/var/madsonic

- ./media:/var/media  # Adjust this path to your media directory

environment:

- PUID=1000  # Set this to your user ID

- PGID=1000  # Set this to your group ID

- TZ=America/New_York  # Set your timezone

restart: unless-stopped

To deploy Madsonic:


nano docker-compose.yml

## 2. Deploy the container

docker-compose up -d

## 3. Verify the container is running

docker-compose ps

Access Madsonic in your browser at http://<your-server-ip>:4040.

πŸš€ Manual Installation

If you prefer a manual setup on a Linux server, follow these steps:


## 1. Install Java (required for Madsonic)

sudo apt update

sudo apt install default-jre -y

## 2. Download the latest Madsonic WAR package

wget https://madsonic.org/download/latest/madsonic-<version>.war -O madsonic.war

## 3. Create directories for Madsonic

sudo mkdir /opt/madsonic

sudo mv madsonic.war /opt/madsonic

## 4. Start Madsonic

cd /opt/madsonic

java -jar madsonic.war &

Madsonic will now be available at http://<your-server-ip>:4040.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To serve Madsonic through Nginx, create a server block configuration file:


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

Add the following:


server {

listen 80;

server_name your-domain.com;

location / {

proxy_pass http://127.0.0.1:4040;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

Enable the configuration and reload Nginx:


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

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Use Let's Encrypt to secure Madsonic with HTTPS:


## Install Certbot

sudo apt install certbot python3-certbot-nginx -y

## Obtain and configure SSL certificates

sudo certbot --nginx -d your-domain.com

## Test auto-renewal

sudo certbot renew --dry-run

Logging and Debugging Madsonic

πŸ—ƒοΈ Enabling Debug Logs

Enable debug-level logging in Madsonic by modifying the startup settings:


java -Dlogging.level.root=DEBUG -jar madsonic.war &

πŸ“„ Viewing Logs

For Docker users:


docker logs madsonic

For manual installations:


tail -f /var/madsonic/madsonic.log

πŸ› οΈ Troubleshooting Common Issues

Look for errors like failed connections or missing files, and verify permissions on media directories:


sudo chmod -R 755 /var/media

πŸ“€ Exporting Logs

Export logs for external analysis:


scp /var/madsonic/madsonic.log user@remote-server:/path/to/logs/

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup Madsonic configuration and media data:


tar -czvf madsonic-backup.tar.gz /opt/madsonic /var/media

πŸ”„ Database Backups

If using an external database, export it:


mysqldump -u username -p madsonic > madsonic_db_backup.sql

πŸ“… Automated Backup Scripts

Set up a cron job for periodic backups:


crontab -e

## Add the following line (weekly backup)

0 2 * * 0 tar -czvf /backup/madsonic-backup-$(date +\%Y-\%m-\%d).tar.gz /opt/madsonic /var/media

Updating and Upgrading Madsonic

⬆️ Updating Docker Images

For Docker users, update Madsonic with:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations:


wget https://madsonic.org/download/latest/madsonic-<version>.war -O madsonic.war

sudo systemctl restart madsonic

πŸ” Checking for Updates

Monitor Madsonic’s official download page for new releases: https://madsonic.org/download.

Leveraging Madsonic’s Unique Features

πŸ”§ Enabling APIs

Enable the REST API for Madsonic to integrate with third-party tools:

  1. Log into Madsonic.

  2. Navigate to Settings > API Settings.

  3. Enable the API and note the API key.

Test the API with curl:


curl -X GET "http://<your-server-ip>:4040/rest/getAlbums" -H "Authorization: Bearer <API_KEY>"

🌟 Advanced Configurations

Modify the Madsonic properties file for advanced settings:


nano /opt/madsonic/madsonic.properties

For example, configure transcoding to improve media playback:


transcoder.default = ffmpeg

Restart the service for changes to take effect:


sudo systemctl restart madsonic

Wrapping Up

This guide provided an in-depth walkthrough for deploying, configuring, and managing Madsonic. From installation via Docker or manual setups to configuring Nginx, enabling logs, and leveraging unique features like its API, Madsonic’s flexibility makes it a powerful self-hosted media platform. Start implementing these steps to take full control of your media streaming experience!

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.