Loading...
Self-hosting paperless-ngx with SQLite on an Ubuntu Server

Self-hosting paperless-ngx with SQLite on an Ubuntu Server

Jonas Scholz - Co-Founder von sliplane.ioJonas Scholz
7 min

Want to digitize your documents without complicated database setup? paperless-ngx with SQLite offers the perfect solution for creating your own secure, self-hosted document management system. This guide shows you how to set it up on Ubuntu Server with automatic HTTPS encryption - all managed through Docker Compose.

In this tutorial, you'll learn how to:

  • Set up a secure Ubuntu server environment
  • Install and configure Docker with Docker Compose
  • Deploy paperless-ngx with SQLite database
  • Secure your installation with Caddy reverse proxy
  • Compare costs with managed hosting solutions

Prerequisites

Before starting, make sure you have:

  • An Ubuntu Linux server with SSH access (we recommend Hetzner Cloud)
  • Basic command line knowledge
  • A domain name (optional but recommended for HTTPS)

Step 1: Update Your Ubuntu Server

First, ensure your Ubuntu server is secure and updated:

sudo apt-get update
sudo apt-get upgrade -y

Your system is now up-to-date and ready for setup.

Step 2: Configure and Secure UFW Firewall

Let's secure your server by configuring the Ubuntu firewall (UFW). We'll allow only ports for HTTP (80), HTTPS (443), and SSH (22):

sudo apt install ufw -y
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable

Check firewall status:

sudo ufw status verbose

Docker can bypass UFW rules, so consider additional protections detailed in this StackOverflow answer.

Step 3: Install Docker Engine and Docker Compose

Docker will manage your containers. To install Docker and Docker Compose, execute these commands:

Install dependencies & Docker GPG key:

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
sudo install -m 0755 -d /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

sudo chmod a+r /etc/apt/keyrings/docker.gpg

Add Docker official repo:

echo \
  "deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

Install Docker and Docker Compose plugin:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

Test Docker installation:

sudo docker run hello-world

If successful, move on to Caddy.

Step 4: Installing Caddy Web Server for Automatic HTTPS

Caddy provides automatic HTTPS certificate management and secure reverse proxy capabilities. This ensures your paperless-ngx installation is protected with industry-standard encryption.

Run the following to install Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
| sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
| sudo tee /etc/apt/sources.list.d/caddy-stable.list

sudo apt update
sudo apt install caddy -y

Now configure the reverse proxy in your Caddyfile:

sudo nano /etc/caddy/Caddyfile

Replace yourdomain.com with your domain:

yourdomain.com {
    reverse_proxy localhost:8000
}

If no domain yet, use port 80 temporarily:

:80 {
    reverse_proxy localhost:8000
}

Restart caddy to load the changes:

sudo systemctl restart caddy

Step 5: Running paperless-ngx with SQLite Using Docker Compose

Create a working folder and Docker compose configuration for paperless-ngx:

mkdir ~/paperless-ngx
cd ~/paperless-ngx

Create a file named docker-compose.yml with the following content:

services:
  broker:
    image: docker.io/library/redis:7
    restart: unless-stopped
    volumes:
      - redisdata:/data

  webserver:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    restart: unless-stopped
    depends_on:
      - broker
    ports:
      - "8000:8000"
    volumes:
      - data:/usr/src/paperless/data
      - media:/usr/src/paperless/media
      - ./export:/usr/src/paperless/export
      - ./consume:/usr/src/paperless/consume
    env_file: docker-compose.env
    environment:
      PAPERLESS_ADMIN_USER: admin
      PAPERLESS_ADMIN_EMAIL: admin@example.com
      PAPERLESS_ADMIN_PASSWORD: adminpassword
      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_URL: https://paperless.sliplane.io
      PAPERLESS_SECRET_KEY: your-secure-random-secret

volumes:
  data:
  media:
  redisdata:

I'd suggest picking a secure secret key for your PAPERLESS_SECRET_KEY environment variable. You can generate a secure key using the following command:

openssl rand -base64 32

The same is true for your PAPERLESS_ADMIN_PASSWORD environment variable!

Save and launch paperless-ngx container:

sudo docker compose up -d

Paperless-ngx is now up and running on your server!

Step 6: Accessing Your Paperless Setup

Open your browser and go to your web address https://yourdomain.com. You should see a login page for paperless-ngx ready for your admin user that you defined in the docker-compose.yml file.

paperless-ngx login

After logging in, you can start uploading and organizing your documents:

paperless-ngx dashboard

Security Recommendations

Maintain secure document storage and server integrity:

  • Set up regular backup routines.
  • Secure SSH with strong passwords or SSH keys.
  • Regularly update client software and apply security patches.
  • Consider tools like fail2ban for extra security.

Updating your paperless-ngx Installation

You can easily update your paperless-ngx installation any time by executing:

sudo docker compose pull
sudo docker compose up -d

Docker will fetch the newest images and automatically update your containers.

Hosting Cost Comparison (Self-Hosted vs Managed)

Self-hosting typically results in lower running costs, giving greater flexibility over managed providers.

ProvidervCPUsRAMDiskCost/month
Render.com12 GB40 GB~$25–35
Fly.io22 GB40 GB~$15–25
Railway22 GB40 GB~$15–30
Sliplane.io22 GB40 GB~€9.50 flat
Hetzner Cloud (self-hosted)22 GB40 GB~€5–10/mo

Although self-hosting offers cost savings, it requires more technical expertise and ongoing maintenance. For a hassle-free experience, consider managed hosting options like sliplane.io.

Next Steps

Now that your paperless-ngx instance is running:

  1. Set up automated backups
  2. Configure document scanning automation
  3. Create custom tags and document categories
  4. Install the mobile app for easy access

Need a simpler solution? Check out our managed hosting at sliplane.io for hassle-free paperless-ngx deployment.

Frequently Asked Questions

Is self-hosting paperless-ngx the best option for everyone?

While self-hosting gives you complete control and can be cost-effective, it requires technical knowledge and ongoing maintenance. If you want a hassle-free experience with professional support, managed solutions like Sliplane offer:

  • Zero maintenance overhead
  • Automatic updates and security patches
  • 24/7 monitoring and support
  • Enterprise-grade backup systems

Can I try sliplane for free?

Yes, you can try Sliplane for free for 2 days. Sign up at sliplane.io and start using paperless-ngx without any commitment.

How do I get started with paperless-ngx?

You have two options:

  1. Self-hosted: Follow this guide to set up your own instance (2-3 hours setup time)
  2. Managed: Sign up with Sliplane for instant deployment (5 minutes setup time)

Both options offer a full paperless-ngx experience, but Sliplane removes the technical complexity while adding enterprise features and support.

Welcome to the container cloud

Sliplane makes it simple to deploy containers in the cloud and scale up as you grow. Try it now and get started in minutes!