Calibre, Part Two

Calibre, Part Two
Photo by Tom Hermans / Unsplash

Install Calibre Server

Step 3 - Running the Calibre Content Server and Viewing Your Library

I'm coming back to this from where I left off yesterday. I had installed a couple additional packages that Calibre is supposed to need to run. So in Calibre's official documentation I have everything mentioned, but that one post they reference lists a few more:

  • libxcb-xinerama0 which I already installed
  • libxcb-icccm4
  • libxcb-image0
  • libxcb-keysyms1
  • libxcb-render-util0

Let's work through installing these packages now.

Steps performed on CALIBRE-01

  • sudo apt install libxcb-icccm4
    • The following NEW packages will be installed:
    • libxcb-icccm4
    • 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  • sudo apt install libxcb-image0
    • The following NEW packages will be installed:
    • libxcb-image0 libxcb-util1
    • 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
  • sudo apt install libxcb-keysyms1
    • The following NEW packages will be installed:
    • libxcb-keysyms1
    • 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  • sudo apt install libxcn-render-util0
    • The following NEW packages will be installed:
    • libxcb-render-util0
    • 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

So I've installed everything off the additional list. So let's uninstall and reinstall Calibre and see if I can get it going.

  • sudo calibre-uninstall
  • sudo sh linux-installer.sh
  • calibredb add .mobi --with-library calibre-library/

Well it ran this time without any errors so it looks like things are all installed properly now. Hooray! I'm back on track!

  • calibre-server calibre-library
    • QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
    • calibre server listening on 0.0.0.0:8080
    • QPDS feeds advertised via BonJour at: 10.10.10.XXX port: 8080

Well that's the output I had been expecting. Victory! Plus, traveling to http://calibre.domain.local:8080 produces a webpage and I can open the book!

Step 4 - Creating a Service for the Calibre Content Server

Steps performed on CALIBRE-01

  • sudo nano /etc/systemd/system/calibre-server.service
## startup service
[Unit]
Description=calibre content server
After=network.target

[Service]
Type=simple
User=david
Group=david
ExecStart=/opt/calibre/calibre-server /home/david/calibre-library --enable-local-write

[Install]
WantedBy=multi-user.target
  • I save the calibre-server.service file
  • sudo systemctl enable calibre-server
  • sudo systemctl start calibre-server
  • sudo reboot

I'm done with step 4. Moving along now!

Step 5 - (Optional) Adding User Authentication to the Calibre Content Server

Steps performed on CALIBRE-01

  • sudo systemctl stop calibre-server
  • calibre-server --manage-users
    • User david added successfully!
  • sudo nano /etc/systemd/system/calibre.service
    • ExecStart=/opt/calibre/calibre-server /home/david/calibre-library --enable-local-write --enable-auth
  • sudo systemctl daemon-reload
  • sudo systemctl start calibre-server

Well the site is now asking for a username/password but it's not accepting what I just set up. Did the copy/paste of the password fail on me?

  • sudo systemctl stop calibre-server
  • calibre-server --manage-users

I add a second test user and change my main account's password.

  • sudo systemctl start calibre-server

It's still not working. It's like it isn't even looking at the database which is where I'm assuming the authentication information would be stored. So looking around online I'm coming up with some wild answer like running a Python command and other nonsense. How about a simple, straight forward solution first? The Calibre developer keeps telling people to use digest authentication instead of basic....which doesn't make sense to me. So what kind of authentication am I using? I don't recall being asked about it. How do I set what kind of authentication I'm using?

I came across this in Calibre's documentation. It's telling you to specify where the user database lives. Well I don't need it to live anywhere special, the default is fine for me. So how do I tell it what kind of authentication it uses? So I found the list of switches you can pass along to calibre-server. Running a test command of:

  • calibre-server --enable-auth --auth-mode basic calibre-library/

The server is now accepting my username and password. I'm logged in. Victory! So I'll need to try it from my service.

  • sudo nano /etc/systemd/system/calibre-server.service
    • ExecStart=/opt/calibre/calibre-server /home/david/calibre-library --enable-local-write --enable-auth --auth-mode basic
  • sudo systemctl daemon-reload
  • sudo systemctl start calibre-server

Well it doesn't like that at all. So how do I feed it this option with a condition? I try every way I could think of and they all fail. I see literally no one using authentication this way at all? That can't be right, how are they doing it? The only solution I can find that seems to come close is people just recommending to use a reverse proxy to feed it HTTPS. OK can I get my reverse proxy working? Shouldn't be a big deal.
Steps performed on NGINX-01

# Configuration for calibre.domain.com
server {
    listen 443;
    server_name calibre.domain.com;
    client_max_body_size 100M;
    location / {
        proxy_set_header Host $host;
        proxy_pass http://calibre.domain.local:8080;
        proxy_redirect off;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Connection "upgrade";
    }
    location /calibre/ {
        proxy_buffering off;
        proxy_pass http://calibre.domain.local:8080$request_uri;
    }
    location /calibre {
        rewrite /calibre /calibre/ permanent;
    }
}

But it still won't authenticate. I just don't get it and all I am doing is spinning my wheels. So I'm going to take a little break from this and take a side step and look at Calibre-Web.