Brool brool (n.) : a low roar; a deep murmur or humming

Setting Up Tiddlywiki Behind Nginx

 |  tiddlywiki coding

I’ve been looking at integrating Tiddlywiki into my daily routine.

The latest incarnation of Tiddlywiki can be run in server mode on top of node. (What, you’ve never tried Tiddlywiki? It’s worth trying just to marvel in its existence – it’s like Emacs and a wiki decided to get together and have a Javascript baby). Anyway, server mode ends up being ideal: since the individual tiddlers are stored in separate text files, it is much easier to track in git and search with Emacs.

Installation is straightforward.

I wanted to have it sit behind a running nginx process – that way it would be easily accessible from any device secured via HTTPS and basic auth. To attach it to a directory (say, /tw) off your Nginx instance, you’ll add this to one of your server blocks.

location /tw/ {
  proxy_set_header        Host             $host;
  proxy_set_header        X-Real-IP        $remote_addr;
  proxy_set_header        X-Forwarded-For  $proxy_add_x_forwarded_for;

Note that the trailing URI on the proxy_pass is important!

I put this in my server block for HTTPS and a redirect off HTTP so that I wouldn’t accidentally use TW off an unencrypted channel.

You’ll need to add a special tiddler to redirect requests to the correct path. In the tiddlers directory for your site, add a file named $__config_tiddlyweb_host.tid, with contents looking like:

title: $:/config/tiddlyweb/host


Finally, you’ll invoke the server:

./node_modules/.bin/tiddlywiki test --server 8080 $:/core/save/all text/plain text/html user pass

… and now you have a Tiddlywiki that you can read anywhere, with backend storage accessible easily.

Other Things To Do

Set up a daily cron to check all your tiddlers into git.

Also, I took the bookmarklet and changed it a little bit to point to my site:

Drag to toolbar and then edit

and then just added a little PHP snippet to update the bookmark tiddler:

text .= "\n[[" . $_GET['title'] . "|" . $_GET['url'] . "]]\n\n"; // add selected text, if any if ($_GET['notes']) { $dat->text .= "<<<\n" . $_GET['notes'] . "\n<<<\n"; } curl_setopt($ch, CURLOPT_URL, ""); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dat)); $response = curl_exec($ch); } curl_close($ch);

Now, just click on a button and it’s automatically added to the bookmarks tiddler. (Actually, there should be a TW extension that does this, but I’m not finding it. Also, you could probably do the whole thing in the bookmarklet, but that is more pain than I am willing to endure at this point.)


Put up all files in this gist to hopefully make it clearer.


Comments are moderated whenever I remember that I have a blog.

Kadir Korkmaz | 2017-04-18 17:49:47
Thank you for this beautiful post. I have been trying to solve this problem for one week. Finally I found the solution :).
Captain Packers | 2017-07-21 12:45:32
I've been looking for a way to set this up for over a year now. I still can't quite get it working. Can you provide more detail about your config files and the URL used to invoke the tiddlywiki?
tim | 2017-07-21 15:26:41
Sure! See addendum.
Alexey | 2019-03-12 17:48:09
Thank you for this post! Almost gave up on this.
Add a comment