Aha! That contained the hint I needed! Thanks.
My main mistake: I didn’t realize that it was a problem to stage the wiki at someplace other than root. Turns out, if I just set that to “/”, with no other changes, my TiddlyWiki works fine. If I change that to something else, the initial startup of the wiki does happen, but only partially, as I described. My full solution below.
Adding “path-prefix=[whatever]” wasn’t necessary in my case.
From one of the pages you linked, “Using a custom path prefix with the client-server edition”:
Configure the client by creating a tiddler called $:/config/tiddlyweb/host that contains $protocol$//$host$/path/to/my/wiki/
That was the missing piece I needed, and I never would have found it on my own, so, much thanks.
Now, in case it helps anybody else: the whole process of making TiddlyWiki available via nginx under SSL, with some arbitrary path name – to allow for more than one TiddlyWiki instance, or whatever else.
First some details/caveats:
- I assume we’re on a NodeJS setup;
- I assume we’re on a Unix-style system, and that we have full control of the shell;
- This is described in a single server, in order to keep out irrelevant details, but wherever possible, I recommend the setup->test->deploy routine;
- In the page I linked above (“Using a custom…”), the TW side of the configuration is done from a page in a TW environment, presumably while the instance is running in the web service’s root directory, and that will immediately change. I want to be able to deploy more than one session, each in one go, so instead, I describe what I did from the shell…
- …which means we need to be sure we have correct ownership and permissions. Details below.
That said:
Let’s assume that all of our TiddlyWiki instances are stored under one base directory, like:
/some/place
For example, say we have:
/some/place/foo
/some/place/bar
/some/place/[…]
For each TW instance, we have a TW shell script. There’s nothing unusual for this; if a wiki is stored at “/some/place/foo/”, then:
#!/bin/sh
cd /some/place && tiddlywiki foo --listen host=localhost port=[PORT]
Important details I’m leaving out:
- We should probably have entries for “readers=”, “username=”, “writers=”, “password=”, maybe others. Details will depend;
- HTTPS needs keys. We’re assuming that your nginx service has that taken care of.
Moving on:
Make an entry in nginx’s config, under the appropriate ‘server’ section. There’s no reason we can’t put this under HTTPS, so within the “listen 443 ssl;” section:
location /foo/ {
proxy_pass http://127.0.0.1:[PORT]/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forewarded-For $proxy_add_x_for_for;
}
On both the shell script and the “location” entry, change “[PORT]” to whatever you choose, as long as it’s consistent. Remember that each instance of the wiki needs its own number, you know what to do.
Then, in the wiki’s source, in the directory ‘/tiddlers/’: make a page, named:
$__config_tiddlyweb_host.tid
So in our example we have:
/some/place/foo/tiddlers/$__config_tiddlyweb_host.tid
Contents of that file:
title: $:/config/tiddlyweb/host
type: text/vnd.tiddlywiki
$protocol$//$host$/[NAME]/
…in this example, [NAME] should be “foo”:
$protocol$//$host$/foo/
When the file is in place, check its permissions. Your details may vary; in our case we have:
-rw-rw-r-- 1 mjinks nginx 148 Mar 16 23:37 '/some/place/foo/tiddlers/$__config_tiddlyweb_host.tid'
The important part is that the nginx process needs read and write on the file. That probably isn’t handled automatically, so (again, your details may vary):
$ sudo chgrp nginx \$__config_tiddlyweb_host.tid
$ sudo chmod 664 \$__config_tiddlyweb_host.tid
$ ls -l \$__config_tiddlyweb_host.tid
-rw-rw-r-- 1 mjinks nginx 148 Mar 16 23:37 '$__config_tiddlyweb_host.tid'
From here on we’re just verifying that our setup is complete and correct.
Make sure the shell script is running. Restart it. Arrange for the script to be started at boot time; how will depend on your system.
Double check your nginx config. Restart that too.
Now with the service up and running we should be able to go to:
https://our.host.name/foo/
On its TW interface, click through to ‘More → System → $:/config/tiddlyweb/host’. In it we should find content something like:
$protocol$//$host$/foo/
…and that’s it! A TiddlyWiki instance upon teh (secure) Intarweb. Maybe. Correct me if I’m wrong, and if I’m not wrong, is there a good place to post this?