Nov 19, 2024 3 min read

Booksonic: A Beginner-Friendly Guide to Self-Hosting

Booksonic: A Beginner-Friendly Guide to Self-Hosting
Table of Contents

Booksonic is a self-hosted audiobook and podcast streaming server, designed to give users complete control over their media collection and access. With its powerful customization options, ease of use, and rich feature set, Booksonic is an excellent choice for audiophiles who value privacy and data ownership. This guide will walk you through installing, configuring, securing, and enhancing your Booksonic server, empowering you to make full use of its capabilities.

Installing Booksonic

πŸ“¦ Docker/Docker Compose Setup

Using Docker is one of the fastest and most reliable ways to deploy Booksonic. Below is an example docker-compose.yml file to set up Booksonic with persistent storage and proper port mappings.


version: '3.8'

services:

booksonic:

image: linuxserver/booksonic

container_name: booksonic

ports:

- 4040:4040

environment:

- PUID=1000            # Your user ID

- PGID=1000            # Your group ID

- TZ=America/New_York  # Set your timezone

volumes:

- /path/to/config:/config  # Persistent configuration storage

- /path/to/media:/audiobooks # Mount your audiobook directory

restart: unless-stopped

To deploy the container:


mkdir -p /path/to/config /path/to/media

docker-compose up -d

Check if the container is running:


docker ps | grep booksonic

πŸš€ Manual Installation

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

  1. Install Java (required for Booksonic):

sudo apt update && sudo apt install -y openjdk-11-jre

  1. Download Booksonic:

wget https://github.com/popeen/Booksonic/releases/download/v1.2/Booksonic.war -P /opt/booksonic

  1. Start Booksonic:

java -jar /opt/booksonic/Booksonic.war --host=0.0.0.0 --port=4040

  1. Access Booksonic:

Open a web browser and navigate to http://<your-server-ip>:4040.

To keep Booksonic running persistently, you can integrate it with a process manager like systemd.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

Nginx can act as a reverse proxy to route traffic to Booksonic securely. Create a server block for Booksonic:


server {

listen 80;

server_name booksonic.example.com;

location / {

proxy_pass http://localhost: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;

proxy_set_header X-Forwarded-Proto $scheme;

}

}

Save this configuration in /etc/nginx/sites-available/booksonic, then enable it:


ln -s /etc/nginx/sites-available/booksonic /etc/nginx/sites-enabled/

nginx -t && systemctl reload nginx

πŸ”’ SSL/TLS Setup

To secure your Booksonic instance with Let's Encrypt:


sudo apt install certbot python3-certbot-nginx

sudo certbot --nginx -d booksonic.example.com

Test automatic certificate renewal:


sudo certbot renew --dry-run

πŸ› οΈ Testing and Reloading Nginx

Ensure the configuration is valid, then reload Nginx:


nginx -t

sudo systemctl reload nginx

Logging and Debugging Booksonic

πŸ—ƒοΈ Enabling Debug Logs

To enable debug-level logging in Booksonic, modify the command used to start the server:


java -Dlogging.level.root=DEBUG -jar /opt/booksonic/Booksonic.war

πŸ“„ Viewing Logs

If running Booksonic in Docker, view logs using:


docker logs -f booksonic

For manual installations, logs are typically stored in:


tail -f /opt/booksonic/booksonic.log

πŸ› οΈ Troubleshooting Common Issues

  • Port Conflicts: Ensure port 4040 is not in use by another application.

  • Java Errors: Verify you have the correct Java version (java -version).

πŸ“€ Exporting Logs

To send logs to an external log management system, you can use tools like Fluentd or Filebeat to ship logs from /opt/booksonic/booksonic.log.

Backup and Restore

πŸ—‚οΈ File-Based Backups

To back up Booksonic’s configuration and media files:


tar -cvzf booksonic-backup.tar.gz /path/to/config /path/to/media

πŸ”„ Database Backups

If Booksonic uses an internal database, back it up with:


cp /path/to/config/db/* /backup-location

πŸ“… Automated Backup Scripts

Schedule regular backups using cron:


crontab -e

Add the following line for daily backups:


0 2 * * * tar -cvzf /backup/booksonic-$(date +\%F).tar.gz /path/to/config /path/to/media

Updating and Upgrading Booksonic

⬆️ Updating Docker Images

To update Booksonic in Docker:


docker-compose pull

docker-compose down

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, download the latest .war file and replace the old one:


wget https://github.com/popeen/Booksonic/releases/latest/download/Booksonic.war -O /opt/booksonic/Booksonic.war

systemctl restart booksonic

πŸ” Checking for Updates

To check for updates:

Leveraging Booksonic’s Unique Features

πŸ”§ Enabling APIs

Booksonic provides API functionality for integration with third-party tools. Enable the API in the web interface under settings, then create an API request:


curl -u username:password "http://<your-server-ip>:4040/rest/getIndexes"

🌟 Advanced Configurations

Customize Booksonic further by editing the booksonic.properties file (located in /path/to/config) to adjust parameters like streaming bitrates, transcoding settings, or allowed file formats.

Wrapping Up

Self-hosting Booksonic allows you to enjoy a personalized audiobook streaming experience while retaining complete control over your data. From installation to security, logging, and backups, this guide has covered all the essentials to get you started. Dive into Booksonic today and unlock its full potential for managing your audiobook library!

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.