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:
-
Log into Madsonic.
-
Navigate to Settings > API Settings.
-
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!