Home Sever Breakdown
Currently in my Uni home I have a RasPi running CasaOs Hosting a server, as I listen to alot of audiobook mostly saved on Audible i have been looking for a way to move away from the service. As I delve deeper home server setups I came across audiobookshelf and realized this would be the perfect solution.
Setup
Luckily I found a Casaos install script on Reddit that pulls directly from the github, but im sure you could find similar on the Appstore of CasaOS:
name: delightful_marc
services:
main_app:
cpu_shares: 90
command: []
container_name: audiobookshelf
deploy:
resources:
limits:
memory: 7827M
image: ghcr.io/advplyr/audiobookshelf
labels:
icon: https://www.audiobookshelf.org/Logo.png
ports:
- target: 13378
published: "13378"
protocol: tcp
- target: 80
published: "13379"
protocol: tcp
restart: unless-stopped
volumes:
- type: bind
source: /data/audiobooks
target: /audiobooks
- type: bind
source: /data/podcasts
target: /podcasts
- type: bind
source: /data/ebooks
target: /ebooks
- type: bind
source: /DATA/AppData/delightful_marc/config
target: /config
- type: bind
source: /DATA/AppData/delightful_marc/metadata
target: /metadata
devices: []
cap_add: []
environment: []
network_mode: bridge
privileged: false
x-casaos:
author: self
category: self
hostname: ""
icon: https://www.audiobookshelf.org/Logo.png
index: /
port_map: "13379"
scheme: http
store_app_id: delightful_marc
title:
custom: audiobookshelf
Just save it to a .yaml file and upload it as a new app or just copy and paste it
Editing time
Next i changed the location from /data/***** to where I downloaded my audiobooks,ebooks and podcasts on my server.
Audiobookshelf setup
Next we’re presented with Account creation for audiobookself, go through this process as standard. and Ta-Dah a place to
Convert Audible to MP3
And I thought they would download as MP3s lmao, so it turns out audible only lets you download .aax audiobooks, and you need a key to unlock them, luckily, I found you can just use ffmpeg to covert them.
ffmpeg -activation_bytes AABBCCDD -i YOURBOOK.aax -codec copy OUTPUT.aac
The activation bytes can be found by a few methods:
- Temporarily install the app and grab the /data/data/com.audible.application/files/AudibleActivation.sys file. Because Android hates it when people can access their own files, you probably need root to do this. Then use either this script, or just grab the first four bytes as hexadecimals in little-endian (backwards notation; reverse them).I didn’t try this as I have a windows vm ready for things like this
- Using the Audible Activator. I tried this but alas not key.
audio books, books and features:
Next I created a library just called audiobooks and books. luckily I have a few other audiobooks/epubs from other platform (Humble bundle a great place for mass books) so I just uploaded these using the webui, Audiobookshelf has a really cool feature that download the metadata for books(covers,authors etc).
There are also some cool features like library stats, personal stats, and a whole host of metadata providers.
Reverse Proxy
Im not gonna give a full tutorial on how to setup a reverse proxy here just use youtube for that, but what I will give you is the code from their github, I would also recommend setting up SSO as there is only a simple login page.
NGINX Reverse Proxy
Add this to the site config file on your nginx server after you have changed the relevant parts in the <> brackets, and inserted your certificate paths.
server
{
listen 443 ssl;
server_name <sub>.<domain>.<tld>;
access_log /var/log/nginx/audiobookshelf.access.log;
error_log /var/log/nginx/audiobookshelf.error.log;
ssl_certificate /path/to/certificate;
ssl_certificate_key /path/to/key;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://<URL_to_forward_to>;
proxy_redirect http:// https://;
}
}
Apache Reverse Proxy
Add this to the site config file on your Apache server after you have changed the relevant parts in the <> brackets, and inserted your certificate paths.
For this to work you must enable at least the following mods using a2enmod:
ssl
proxy
proxy_http
proxy_balancer
proxy_wstunnel
rewrite
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName <sub>.<domain>.<tld>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ProxyPass / http://localhost:<audiobookshelf_port>/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://localhost:<audiobookshelf_port>/$1" [P,L]
# unless you're doing something special this should be generated by a
# tool like certbot by let's encrypt
SSLCertificateFile /path/to/cert/file
SSLCertificateKeyFile /path/to/key/file
</VirtualHost>
</IfModule>
This along side using a self-cert option like Let’s Encrypts certbot to get SSL Certificates should allow you to have the service accessible from the internet.