Back to articles
DevOps & Systems

Comprehensive Guide to Building a Private Ebook Library with Calibre Web on a Clone VPS

This guide provides a step-by-step implementation of a private ebook library using Calibre Web on a clone VPS, leveraging Docker, Nginx, and SSL for secure remote access. Designed...

DPTCloud Engineering4 min read
Comprehensive Guide to Building a Private Ebook Library with Calibre Web on a Clone VPS

Image credit: Perfecto_Capucine · Pixabay Content License

This guide provides a step-by-step implementation of a private ebook library using Calibre Web on a clone VPS, leveraging Docker, Nginx, and SSL for secure remote access. Designed for DevOps professionals, it covers setup, configuration, security hardening, synchronization, and performance optimization in a self-hosted environment.

Introduction

Building a private ebook library on a VPS allows you to manage, access, and share digital books remotely with full control over your data. This guide walks you through deploying Calibre Web, a powerful web interface for the Calibre ebook management system, on a clone VPS using Docker and Nginx. The setup ensures high security, scalability, and integration with DevOps workflows, making it ideal for individuals and organizations managing personal or shared book collections.

Prerequisites

  • A clone VPS running Linux (Ubuntu 22.04 or equivalent).
  • SSH access to the VPS.
  • Docker and Docker Compose installed.
  • A registered domain or subdomain (e.g., books.yourdomain.com).
  • SSL/TLS certificate (Let's Encrypt recommended).

Setting Up Calibre Web on the VPS

Calibre Web provides a modern web-based interface to manage and serve ebooks from your Calibre library. Follow these steps to deploy it on your VPS.

1. Install Docker and Docker Compose

Run the following commands on your VPS:

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

2. Create Data and Configuration Directories

Prepare directories for persistent storage:

mkdir -p /opt/calibre-web/data /opt/calibre-web/config

3. Create the docker-compose.yml File

Generate a configuration file at /opt/calibre-web/docker-compose.yml:

version: '3.8'
services:
  calibre-web:
    image: koyfin/calibre-web:latest
    container_name: calibre-web
    volumes:
      - /opt/calibre-web/data:/data
      - /opt/calibre-web/config:/config
    ports:
      - "8083:8083"
    environment:
      - TZ=Asia/Ho_Chi_Minh
      - CALIBRE_WEB_USERNAME=admin
      - CALIBRE_WEB_PASSWORD=your_secure_password
    restart: unless-stopped

4. Start the Service

Launch the Calibre Web container:

cd /opt/calibre-web
sudo docker-compose up -d

Optimization and Security

To ensure security and performance, configure Nginx as a reverse proxy with SSL encryption.

1. Install Nginx and Certbot

Install required packages:

sudo apt update
sudo apt install nginx certbot

2. Create Nginx Configuration

Generate a site configuration file at /etc/nginx/sites-available/calibre-web:

server {
    listen 80;
    server_name books.yourdomain.com;

    location / {
        proxy_pass http://localhost:8083;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

3. Configure SSL with Let's Encrypt

Obtain a free SSL certificate:

sudo certbot certonly --nginx -d books.yourdomain.com

4. Update Nginx for HTTPS

Modify the configuration to enable HTTPS:

server {
    listen 443 ssl;
    server_name books.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/books.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/books.yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://localhost:8083;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Verification and Testing

Validate your setup with the following steps:

  • Open a web browser and navigate to https://books.yourdomain.com.
  • Log in using the username admin and your configured password.
  • Upload a sample ebook (PDF, EPUB, or MOBI) to verify functionality.

Troubleshooting

  • Website not accessible: Run sudo docker-compose ps to confirm the container is running.
  • SSL certificate errors: Renew the certificate with sudo certbot renew.
  • Upload failures: Check directory permissions on /opt/calibre-web/data.

References

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478