Calibre Server Setup

Setting up a Calibre book server for you epubs (with a URL prefix).

Step 1: Install Calibre

First, we need to install Calibre on the server:


apt install -y calibre
mkdir /opt/calibre
      

Step 2: Create the Calibre library

Next, we create the Calibre library where our books will be stored:


rsync -avuP your-library-dir root@nargothrond.xyz:/opt/calibre/
calibredb add /opt/calibre/your-local-dir/*.epub \
 --with-library nargothrond-library
      
Add a user to protect your books like this:

calibre-server --manage-users
      

Step 3: Create a Systemd Service

So the Calibre server starts automatically on boot, we create a systemd service (the option "--url-prefix /calibre" is imperative if you want to use a url prefix ... Calibre doc here:


vim /etc/systemd/system/calibre-server.service

[Unit]
Description=Calibre library server
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/bin/calibre-server \
--enable-auth --enable-local-write /opt/calibre/nargothrond-library \
--listen-on 127.0.0.1 --url-prefix /calibre --port 8080

[Install]
WantedBy=multi-user.target
    

Now you can start and start your Calibre server as below shown:


systemctl daemon-reload
systemctl enable calibre-server
systemctl start calibre-server
    

Or to start debugging your Calibre server:


systemctl status calibre-server
systemctl restart calibre-server
      

Step 4: Configure Nginx

Add a Calibre block to your existing URL prefix Nginx server config:


vim /etc/nginx/sites-available/mywebsite

proxy_set_header X-Forwarded-For $remote_addr;
location /calibre/ {
    proxy_buffering off;
    proxy_pass http://127.0.0.1:8080$request_uri;
 }
location /calibre {
    # we need a trailing slash for the Application Cache to work
    rewrite /calibre /calibre/ permanent;
 }
    
Back to Home