Calibre - Cross Platform Open Source eBook Suite
A cross-platform free and open-source suite of e-book software

1. Background
Calibre is a cross-platform free and open-source suite of e-book software. Calibre supports organizing existing e-books into virtual libraries, displaying, editing, creating and converting e-books, as well as syncing e-books with a variety of e-readers. Editing books is supported for EPUB and AZW3 formats.
In this article, I will introduce the deployment of Calibre and CalibreWeb via Docker.
- Calibre will serve as backend ebook management, including import books
- CalibreWeb will serve as web UI, to read or download ebooks
2. Calibre
- Prerequisites
apt -y update
apt -y install curl nginx python3-certbot-nginx
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
- Calibre compose file
cd /your/path
mkdir calibre && cd calibre
nano docker-compose.yml
version: "3.8"
services:
calibre:
image: lscr.io/linuxserver/calibre:latest
container_name: calibre
security_opt:
- seccomp:unconfined #optional
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- PASSWORD=your_calibre_password #optional
- CLI_ARGS= #optional
volumes:
- ./data:/config
ports:
- 127.0.0.1:40001:8080
# - 8181:8181
# - 8081:8081
restart: unless-stopped
- Bring up the container
docker compose up -d
Note: The ebooks library is now located in /your/path/calibre/data/Calibre Library/
on your server.
3. CalibreWeb
cd /your/path
mkdir calibreweb && cd calibreweb
nano docker-compose.yml
version: "3.8"
services:
calibre-web:
image: lscr.io/linuxserver/calibre-web:latest
container_name: calibre-web
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- DOCKER_MODS=linuxserver/mods:universal-calibre #optional
- OAUTHLIB_RELAX_TOKEN_SCOPE=1 #optional
volumes:
- ./data:/config
- /your/path/calibre/data/Calibre Library:/books
ports:
- 127.0.0.1:40002:8083
restart: unless-stopped
Note: Make sure that you match the volume /your/path/calibre/data/Calibre Library:/books
to the previous path.
- Bring up the container
docker compose up -d
Now Calibre service is on localhost:40001
, and CalibreWeb service is on localhost:40002
4. Nginx Setup
Since we have both Calibre (to upload ebooks) and CalibreWeb (to view them) and need to access them via web, Nginx SNI is needed.
- Edit nginx.conf
nano /etc/nginx/nginx.conf
Add a block at the bottom
stream {
map $ssl_preread_server_name $example_sni {
calibre.example.com calibre;
calibreweb.example.com calibreweb;
}
upstream calibre {
server 127.0.0.1:40003;
}
upstream calibreweb {
server 127.0.0.1:40004;
}
server {
listen 443 reuseport;
listen [::]:443 reuseport;
proxy_pass $henry_xray;
ssl_preread on;
}
}
- Create port 80 https redirect
nano /etc/nging/conf.d/httpsredirect.conf
server {
listen 80;
server_name calibre.example.com;
if ($host = calibre.example.com) {
return 301 https://$host$request_uri;
}
server_name calibreweb.example.com;
if ($host = calibreweb.example.com) {
return 301 https://$host$request_uri;
}
}
- Issue SSL cert for both calibre.example.com and calibreweb.example.com
certbot --nginx
- Create calibre.conf
server {
listen 127.0.0.1:40003 ssl http2;
ssl_certificate /your/cert/path/fullchain.pem;
ssl_certificate_key /your/cert/path/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
server_name calibre.example.com;
client_max_body_size 2G;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:40001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
- Create calibreweb.conf
server {
listen 127.0.0.1:40004 ssl http2;
ssl_certificate /your/cert/path/fullchain.pem;
ssl_certificate_key /your/cert/path/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
server_name calibreweb.example.com;
client_max_body_size 2G;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:40002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
- Restart Nginx
nginx -t
systemctl restart nginx
5. Post Configuration
- Now you can visit calibre.example.com to upload ebooks. Remember to upload them to the correct directory, which in the web is
/config/Calibre Library/
. - Also, go to calibreweb.example.com and set the Calibre Database Directory to
/books
Note: Please pay attention to copyright, and support genuine.



Copyright statement: Unless otherwise stated, all articles on this blog adopt the CC BY-NC-SA 4.0 license agreement. For non-commercial reprints and citations, please indicate the author: Henry, and original article URL. For commercial reprints, please contact the author for authorization.