Jul 21, 2024 3 min read

TiddlyWiki: Simplifying Self-Hosting

TiddlyWiki: Simplifying Self-Hosting
Table of Contents

TiddlyWiki is a lightweight, highly customizable self-contained wiki designed for personal knowledge management and project documentation. Its single-file architecture and powerful plugin ecosystem make it an excellent option for self-hosting, offering full control over your data and environment. This guide will walk you through the process of installing, configuring, and managing TiddlyWiki, including steps for setting up a reverse proxy, enabling logging, automating backups, and leveraging its unique features.

Installing TiddlyWiki

πŸ“¦ Docker/Docker Compose Setup

Using Docker is one of the easiest ways to deploy TiddlyWiki. Below is a docker-compose.yml file optimized for a self-hosted setup:


version: "3.8"

services:

tiddlywiki:

image: node:current-alpine

container_name: tiddlywiki

volumes:

- ./data:/wiki

ports:

- "8080:8080"

working_dir: /wiki

command: >

sh -c "npm install -g tiddlywiki &&

tiddlywiki ./wiki --init server --listen port=8080 host=0.0.0.0"

Run the following commands to deploy TiddlyWiki:


mkdir -p ~/tiddlywiki/data

## Navigate to the directory and create the docker-compose.yml file

cd ~/tiddlywiki

nano docker-compose.yml

## Start the container

docker-compose up -d

πŸš€ Manual Installation

For those who prefer a manual setup on a Linux server, here’s how to install and run TiddlyWiki:


## Update the system and install Node.js

sudo apt update && sudo apt upgrade -y

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

sudo apt install -y nodejs

## Install TiddlyWiki globally

sudo npm install -g tiddlywiki

## Initialize and run your TiddlyWiki instance

mkdir ~/tiddlywiki

cd ~/tiddlywiki

tiddlywiki ./wiki --init server

tiddlywiki ./wiki --listen port=8080 host=0.0.0.0

TiddlyWiki will now be available on http://<your-server-ip>:8080.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To serve TiddlyWiki via a domain, configure Nginx as a reverse proxy:


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

Add the following configuration:


server {

listen 80;

server_name yourdomain.com;

location / {

proxy_pass http://localhost:8080;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection 'upgrade';

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}

}

Activate the configuration and restart Nginx:


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

sudo nginx -t

sudo systemctl restart nginx

πŸ”’ SSL/TLS Setup

Secure your installation with Let's Encrypt:


sudo apt install certbot python3-certbot-nginx -y

sudo certbot --nginx -d yourdomain.com

sudo systemctl reload nginx

πŸ› οΈ Testing and Reloading Nginx

Verify that Nginx is configured correctly and reload the service:


sudo nginx -t

sudo systemctl reload nginx

Logging and Debugging TiddlyWiki

πŸ—ƒοΈ Enabling Debug Logs

Enable debug-level logging in TiddlyWiki by appending the debug-level flag to your startup command:


tiddlywiki ./wiki --listen port=8080 host=0.0.0.0 debug-level=debug

πŸ“„ Viewing Logs

If you're running TiddlyWiki in Docker, view logs with:


docker logs tiddlywiki

For manual setups, logs will appear in the terminal output or can be redirected to a file:


tiddlywiki ./wiki --listen port=8080 host=0.0.0.0 > tiddlywiki.log 2>&1

πŸ› οΈ Troubleshooting Common Issues

If TiddlyWiki fails to start, verify the following:

  • Port conflicts: Ensure no other services are using the same port.

  • Node.js version: Use a supported version (Node.js 14+).

πŸ“€ Exporting Logs

Send logs to an external log management system like ELK Stack using Filebeat or similar tools. Example Filebeat configuration snippet:


filebeat.inputs:

- type: log

paths:

- /path/to/tiddlywiki.log

Backup and Restore

πŸ—‚οΈ File-Based Backups

For file-based installations, back up the wiki directory:


tar -czvf tiddlywiki-backup.tar.gz ~/tiddlywiki/wiki

πŸ”„ Database Backups

If using a database plugin, export the data using the plugin’s documentation and commands.

πŸ“… Automated Backup Scripts

Create a cron job to automate backups:


echo "0 2 * * * tar -czvf ~/tiddlywiki-backup-$(date +\%F).tar.gz ~/tiddlywiki/wiki" | crontab -

Updating and Upgrading TiddlyWiki

⬆️ Updating Docker Images

Update your Dockerized TiddlyWiki instance:


docker-compose pull

docker-compose down

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, update TiddlyWiki globally:


sudo npm install -g tiddlywiki

πŸ” Checking for Updates

Verify the installed version of TiddlyWiki:


tiddlywiki --version

Leveraging TiddlyWiki’s Unique Features

πŸ”§ Enabling APIs

Enable the REST API for TiddlyWiki by starting it with the credentials option:


tiddlywiki ./wiki --listen port=8080 host=0.0.0.0 username=user password=pass

Access the API using curl:


curl -u user:pass http://localhost:8080

🌟 Advanced Configurations

Customize TiddlyWiki further by editing the $:/config tiddlers from the graphical interface. You can also integrate third-party tools like Pandoc for exporting wikis to other formats.

Wrapping Up

This guide covered the essentials of deploying, configuring, and managing TiddlyWiki, including Docker setups, Nginx reverse proxying, logging, backups, and updates. Self-hosting TiddlyWiki grants you unparalleled flexibility and control over your data. With these steps, you’re ready to fully exploit TiddlyWiki’s robust capabilities. Dive in, customize, and enjoy!

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.