Jul 21, 2024 3 min read

Joplin Server: A Complete Checklist for Self-Hosting Success

Joplin Server: A Complete Checklist for Self-Hosting Success
Table of Contents

Joplin Server is the self-hosted synchronization backend for the popular open-source note-taking app, Joplin. It allows users to sync their notes, notebooks, attachments, and tasks across devices while maintaining full control of their data. By hosting Joplin Server yourself, you gain customization options, enhanced security, and independence from third-party services. This guide provides step-by-step instructions to install, configure, manage, and leverage Joplin Server to its fullest potential.

Installing Joplin Server

πŸ“¦ Docker/Docker Compose Setup

Docker Compose is the easiest and most efficient way to deploy Joplin Server. Below is a complete docker-compose.yml tailored for Joplin Server. It includes a PostgreSQL database and volume configurations for persistent storage.

  1. Create a directory for Joplin Server:

mkdir -p ~/joplin-server && cd ~/joplin-server

  1. Create a docker-compose.yml file:

version: "3.8"

services:

db:

image: postgres:15

volumes:

- ./data/postgres:/var/lib/postgresql/data

environment:

POSTGRES_USER: joplin

POSTGRES_PASSWORD: joplinpassword

POSTGRES_DB: joplin

restart: always

app:

image: joplin/server:latest

ports:

- "22300:22300"

environment:

APP_BASE_URL: "http://yourdomain.com" # Update with your domain

DB_CLIENT: "pg"

POSTGRES_PASSWORD: "joplinpassword"

POSTGRES_DATABASE: "joplin"

POSTGRES_USER: "joplin"

POSTGRES_PORT: 5432

POSTGRES_HOST: "db"

NODE_ENV: "production"

depends_on:

- db

restart: always

  1. Deploy the stack using Docker Compose:

docker-compose up -d

  1. Verify the deployment:

docker ps

curl http://localhost:22300/api/ping

πŸš€ Manual Installation

For users who prefer manual installation, below are the steps to set up Joplin Server directly on a Linux server.

  1. Install Node.js and PostgreSQL:

sudo apt update

sudo apt install -y nodejs npm postgresql

  1. Clone the Joplin Server repository:

git clone https://github.com/laurent22/joplin.git

cd joplin/packages/server

  1. Install dependencies:

npm install

  1. Configure the database in PostgreSQL:

sudo -u postgres psql

CREATE DATABASE joplin;

CREATE USER joplin WITH PASSWORD 'joplinpassword';

GRANT ALL PRIVILEGES ON DATABASE joplin TO joplin;

\q

  1. Run the server:

APP_BASE_URL=http://yourdomain.com DB_CLIENT=pg \

POSTGRES_DATABASE=joplin POSTGRES_USER=joplin POSTGRES_PASSWORD=joplinpassword \

POSTGRES_HOST=localhost POSTGRES_PORT=5432 \

npm start

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To route traffic through Nginx and serve Joplin Server at your domain, create the following Nginx server block:

  1. Create an Nginx configuration file:

sudo nano /etc/nginx/sites-available/joplin

  1. Add the server block:

server {

server_name yourdomain.com;

location / {

proxy_pass http://localhost:22300;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

}

listen 80;

}

  1. Enable the configuration:

sudo ln -s /etc/nginx/sites-available/joplin /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your domain with Let's Encrypt using Certbot:

  1. Install Certbot:

sudo apt install -y certbot python3-certbot-nginx

  1. Obtain and apply an SSL certificate:

sudo certbot --nginx -d yourdomain.com

  1. Automate certificate renewals:

sudo systemctl enable certbot.timer

πŸ› οΈ Testing and Reloading Nginx

Test the Nginx configuration for issues and reload:


sudo nginx -t

sudo systemctl reload nginx

Logging and Debugging Joplin Server

πŸ—ƒοΈ Enabling Debug Logs

Enable debug logging for Joplin Server by setting LOG_LEVEL to debug in your environment variables:


LOG_LEVEL=debug

For Docker Compose, add this to the app service in docker-compose.yml:


environment:

LOG_LEVEL: debug

Restart the container:


docker-compose restart

πŸ“„ Viewing Logs

Access logs to monitor the server:

  • Docker:

docker logs -f joplin-server_app_1

  • Manual installation:

tail -f logs/app.log

πŸ› οΈ Troubleshooting Common Issues

Common errors are often database-related. Check connectivity:


psql -U joplin -h localhost -d joplin -c "\dt"

Ensure environmental variables in docker-compose.yml or .env are accurate.

πŸ“€ Exporting Logs

To forward logs to an ELK stack:

  1. Install Filebeat on your server.

  2. Configure it to watch log files:


filebeat.inputs:

- type: log

paths:

- /path/to/app.log

  1. Restart Filebeat:

systemctl restart filebeat

Backup and Restore

πŸ—‚οΈ File-Based Backups

Back up your server configurations:


tar -czvf joplin-config-backup.tar.gz ~/joplin-server

πŸ”„ Database Backups

Export the database:


pg_dump -U joplin -h localhost joplin > joplin-backup.sql

Restore the database:


psql -U joplin -h localhost -d joplin -f joplin-backup.sql

πŸ“… Automated Backup Scripts

Automate backups with a cron job:


crontab -e

0 2 * * * pg_dump -U joplin -h localhost joplin > ~/backups/joplin-$(date +\%F).sql

Updating and Upgrading Joplin Server

⬆️ Updating Docker Images

To update Joplin Server when using Docker:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

If installed manually, pull the latest code and rebuild:


cd ~/joplin/packages/server

git pull

npm install

npm start

πŸ” Checking for Updates

Monitor the Joplin Server GitHub repository for release notes and updates.

Leveraging Joplin Server’s Unique Features

πŸ”§ Enabling APIs

Joplin Server includes a robust API. To enable it, ensure APP_BASE_URL is set, then test an endpoint:


curl http://yourdomain.com/api/ping

🌟 Advanced Configurations

Integrate third-party tools like Prometheus for monitoring or configure rate-limiting using Nginx:


limit_req_zone $binary_remote_addr zone=mylimit:10m rate=5r/s;

Wrapping Up

By deploying and managing Joplin Server, you gain full control over your data synchronization and note management. This guide covers every essential step, from installation and configuration to backups and updates, empowering you to customize and secure your self-hosted environment. Start exploring the provided code examples to unlock the full potential of Joplin Server for your workflow!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.