De calibre Content server

De calibre: guilabel: inhoudsserver geeft u toegang tot uw calibre bibliotheken en leest boeken direct in een browser op uw favoriete mobiele telefoon of tablet. Als gevolg hiervan hoeft u geen speciale apps voor het lezen/beheren van boeken op uw telefoon te installeren. Gebruik gewoon de browser. De server downloadt en bewaart het boek dat u leest in een off-line buffer, zodat u het kunt lezen, zelfs als er geen internetverbinding is.

Om de server te starten, klikt u op de: guilabel: verbinden/delen ` knop en kiest: guilabel: Start inhoudsserver`. Mogelijk ontvangt u een bericht van de firewall of het antivirusprogramma van uw computer met de vraag of het OK is om toegang te verlenen tot `` calibre.exe``. Klik op de knop `` Toestaan`` of `` OK``. Open vervolgens een browser (bij voorkeur Chrome of Firefox) op uw computer en typ het volgende adres:

http://127.0.0.1:8080

Dit opent een pagina in de browser die u uw calibre bibliotheken toont, klikt op een browser en blader door de boeken erin. Klik op een boek en het toont u alle metadata over het boek, samen met de knoppen om: guilabel: Leesboek en: guilabel:` Download boek`. Klik op de: guilabel: Lees boek knop om te beginnen met het lezen van het boek.

Notitie

Het adres dat boven `` http: //127.0.0.1: 8080`` wordt gebruikt, werkt alleen op de computer die calibre draait. Om toegang te krijgen tot de server vanaf andere computers/telefoons/tablets/enz. u zult wat meer werk moeten doen, zoals beschreven in de volgende sectie.

Toegang krijgen tot de Content server vanaf andere toestellen

Er zijn twee typen van externe apparaat toegang die u normaal gesproken nodig heeft. De eerste, eenvoudigere soort is vanuit uw thuisnetwerk. Als u calibre draait op een computer in uw thuisnetwerken en ook uw andere apparaten op hetzelfde thuisnetwerk hebt aangesloten, moet u gemakkelijk toegang hebben tot de server op die apparaten.

Toegang krijgen tot de server vanaf apparaten in uw thuisnetwerk

Na starten van de server in calibre zoals boven beschreven, klik terug op de Verbinden/delen knop. In plaats van de Start Content server zou u een Stop Content server actie moeten zien. Rechts van deze actie staat een IP adres en een poort nummer. Deze lijken op een hoop getallen gescheiden door punten. Bijvoorbeeld:

Stop Content server [192.168.1.5, port 8080]

Deze getallen zeggen u welk adres te gebruiken om te verbinden met de server in uw toestel. Volgens het voorbeeld boven wordt het adres:

http://192.168.1.5:8080

Het eerste deel van het adres is altijd http:// het volgende deel is het IP adres, de nummers voor de komma, en tenslotte het poortnummer dat wordt toegevoegd aan het IP adres met een dubbel punt (:). Als u geluk hebt, is dit alles dat u nodig hebt en kijkt u nu naar de calibre bibliotheken op uw toestel. Indien niet, lees verder.

Problemen oplossen voor de thuisnetwerkverbinding

Als u niet met de server kan verbinden vanop uw toestel, probeer volgende stappen:

  1. Controleer of de server draait door naar http://127.0.0.1:8080 te gaan in een browser op dezelfde computer als de server.

  2. Controleer of uw firewall en anti-virus verbindingen toelaten naar uw computer op poort 8080 en het calibre programma. De gemakkelijkste manier om firewall en anti-virus als bron van problemen te elimineren is ze tijdelijk uit te schakelen en dan proberen te verbinden. U moet eerst de internet verbinding verbreken vóór de firewall uit te schakelen om uw computer niet onbeschermd te laten.

  3. Controleer of uw computer en toestel op hetzelfde netwerk zitten. Dit betekent dat ze beiden met dezelfde draadloze router verbonden zijn. Vooral, ze mogen geen mobiele telefoon of ISP geleverde WiFi verbinding gebruiken.

  4. Als u een niet-standaard netwerkopstelling hebt, kan het zijn dat het IP adres, getoond in het Verbinden/delen menu fout is. In zulk geval moet u zelf uitzoeken wat het correcte te gebruiken IP adres is. Spijtig genoeg is het onmogelijk u daarvoor een stappenplan te geven gezien het oneindige aantal mogelijke configuraties.

  5. Als u een gebruikersnaam en wachtwoord hebt ingesteld, probeer eerst zonder om te zien of dat problemen oplevert. Sommige e-inkt toestellen hebben browsers die geen authenticatie kunnen afhandelen. U kan dit soms omzeilen door gebruikersnaam en wachtwoord in te sluiten in de URL, bv.: http://gebruikersnaam:wachtwoord@192.168.1.2:8080.

  6. Als u vast zit kan u altijd hulp vragen in de calibre gebruikersforums.

Toegang krijgen tot de server van overal op het internet

Waarschuwing

Before doing this you should turn on username/password protection in the server, otherwise anyone in the world will be able to access your books. Go to Preferences → Sharing → Sharing over the net and enable the option to Require username and password to access the content server.

While the particular details on setting up internet access vary depending on the network configuration and type of computer you are using, the basic schema is as follows.

  1. Find out the external IP address of the computer you are going to run the server on. You can do that by visiting the site What is my IP address in a browser running on the computer.

  2. If the computer is behind a router, enable port forwarding on the router to forward the port 8080 (or whatever port you choose to run the calibre Content server on) to the computer.

  3. Make sure the calibre server is allowed through any firewalls/anti-virus programs on your computer.

  4. Now you should be able to access the server on any internet-connected device using the IP address you found in the first step. For example, if the IP address you found was 123.123.123.123 and the port you are using for the calibre server is 8080, the address to use on your device becomes: http://123.123.123.123:8080.

  5. Optionally, use a service like no-ip to setup an easy to remember address to use instead of the IP address you found in the first step.

Notitie

For maximum security, you should also enable HTTPS on the Content server. You can either do so directly in the server by providing the path to the HTTPS certificate to use in the advanced configuration options for the server, or you can setup a reverse proxy as described below, to use an existing HTTPS setup.

The server interface

The server interface is a simplified version of the main calibre interface, optimised for use with touch screens. The home screen shows you books you are currently reading as well as allowing to choose a calibre library you want to browse. The server in calibre gives you access to all your libraries, not just a single one, as before.

The book list

The server book list is a simple grid of covers. Tap on a cover to see the detailed metadata for a book, or to read the book. If you prefer a more detailed list, you can change the default view by clicking the three vertical dots in the top right corner.

Sorting and searching of the book list should be familiar to calibre users. They can be accessed by clicking their icons in the top right area. They both work exactly the same as in the main calibre program. The search page even allows you to construct search queries by clicking on authors/tags/etc., just as you can using the Tag browser in the main program.

A much loved feature of the main program, Virtual libraries is present in the server interface as well. Click the three vertical dots in the top right corner to choose a Virtual library.

The book reader

You can read any book in your calibre library by simply tapping on it and then tapping the Read book button. The books reader is very simple to operate. You can both tap and swipe to turn pages. Swiping up/down skips between chapters. Tapping the top quarter of the screen gets you the detailed controls and viewer preferences.

If you leave the Content server running, you can even open the same book on multiple devices and it will remember your last read position. If it does not you can force a sync by tapping in the top quarter and choosing Sync.

Browser support

The new calibre server makes lots of use of advanced HTML 5 and CSS 3 features. As such it requires an up-to-date browser to use. It has been tested on Android Chrome and iOS Safari as well as Chrome and Firefox on the desktop.

The server is careful to use functionality that has either been already standardised or is on the standards track. As such if it does not currently work with your favorite browser, it probably will once that browser has caught up.

If you are using a particularly old or limited browser or you don’t like to run JavaScript, you can use the mobile view, by simply adding /mobile to the server address.

Notitie

On iOS, Apple allows only a single browser engine, so Firefox, Chrome and Safari are all actually the same browser under the hood. The new server interface requires iOS 10.3.2 or newer. On Android, the server has been tested with Chrome version 58 and newer.

Enabling offline support

Browser makers have been trying to force people to use SSL by disabling advanced features in their browsers for plain HTTP connections. One such casualty is offline support. So you may need to enable HTTPS on the server to get offline support working. In addition, in Firefox on Android, you will need to type about:config and search for browser.tabs.useCache and toggle it to true.

Managing user accounts from the command-line only

The calibre program has a nice section in Preferences to allow you to manage user accounts for the server. However, if you want to run the standalone server and cannot run the main calibre program on the same computer/user account, you can also manage users using just the command-line.

You can manage user accounts using the --manage-users option to the standalone calibre-server program. Suppose you want to store the user database in the folder /srv/calibre, then you create it by running:

calibre-server --userdb /srv/calibre/users.sqlite --manage-users

Just follow the prompts to create user accounts, set their permission, etc. Once you are done, you can run the server as:

calibre-server --userdb /srv/calibre/users.sqlite --enable-auth

It will use the user accounts you created in the previous step.

Integratie van de Calibre Content-server in andere servers

Here, we will show you how to integrate the calibre Content server into another server. The most common reason for this is to make use of SSL or to serve the calibre library as part of a larger site. The basic technique is to run the calibre server and setup a reverse proxy to it from the main server.

A reverse proxy is when your normal server accepts incoming requests and passes them onto the calibre server. It then reads the response from the calibre server and forwards it to the client. This means that you can simply run the calibre server as normal without trying to integrate it closely with your main server.

Using a full virtual host

The simplest configuration is to dedicate a full virtual host to the calibre server. In this case, run the calibre server as:

calibre-server

Now setup the virtual host in your main server, for example, for nginx:

http {
    client_max_body_size 64M;  # needed to upload large books
}

server {
    listen [::]:80;
    server_name myserver.example.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }
}

Or, for Apache:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<VirtualHost *:80>
    ServerName myserver.example.com
    AllowEncodedSlashes On
    ProxyPreserveHost On
    ProxyPass "/"  "http://localhost:8080/"
</VirtualHost>

Using a URL prefix

If you do not want to dedicate a full virtual host to calibre, you can have it use a URL prefix. Start the calibre server as:

calibre-server --url-prefix /calibre --port 8080

The key parameter here is --url-prefix /calibre. This causes the Content server to serve all URLs prefixed by /calibre. To see this in action, visit http://localhost:8080/calibre in your browser. You should see the normal Content server website, but now it will run under /calibre.

With nginx, the required configuration is:

http {
    client_max_body_size 64M;  # needed to upload large books
}

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;
}

For Apache, first enable the proxy modules in Apache, by adding the following to httpd.conf:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

The exact technique for enabling the proxy modules will vary depending on your Apache installation. Once you have the proxy modules enabled, add the following rules to httpd.conf (or if you are using virtual hosts to the conf file for the virtual host in question):

AllowEncodedSlashes On
RewriteEngine on
RewriteRule ^/calibre/(.*) http://127.0.0.1:8080/calibre/$1 [proxy]
RedirectMatch permanent ^/calibre$ /calibre/

That’s all, you will now be able to access the calibre Content server under the /calibre URL in your main server. The above rules pass all requests under /calibre to the calibre server running on port 8080 and thanks to the --url-prefix option above, the calibre server handles them transparently.

Notitie

When using a reverse proxy, you should tell the calibre Content server to only listen on localhost, by using --listen-on 127.0.0.1. That way, the server will only listen for connections coming from the same computer, i.e. from the reverse proxy.

Notitie

If you have setup SSL for your main server, you should tell the calibre server to use basic authentication instead of digest authentication, as it is faster. To do so, pass the --auth-mode=basic option to calibre-server.

Creating a service for the calibre server on a modern Linux system

You can easily create a service to run calibre at boot on a modern (systemd) based Linux system. Just create the file /etc/systemd/system/calibre-server.service with the contents shown below:

[Unit]
Description=calibre Content server
After=network.target

[Service]
Type=simple
User=mylinuxuser
Group=mylinuxgroup
ExecStart=/opt/calibre/calibre-server "/path/to/calibre library folder"

[Install]
WantedBy=multi-user.target

Change mylinuxuser and mylinuxgroup to whatever user and group you want the server to run as. This should be the same user and group that own the files in the calibre library folder. Note that it is generally not a good idea to run the server as root. Also change the path to the calibre library folder to suit your system. You can add multiple libraries if needed. See the help for the calibre-server command.

Now run:

sudo systemctl start calibre-server

to start the server. Check its status with:

sudo systemctl status calibre-server

To make it start at boot, run:

sudo systemctl enable calibre-server

Notitie

The calibre server does not need a running X server, but it does need the X libraries installed as some components it uses link against them.

Notitie

The calibre server also supports systemd socket activation, so you can use that, if needed, as well.