How to get TiddlyWiki running behind Nginx

486 views
Skip to first unread message

Charles Anderson

unread,
Feb 13, 2021, 7:42:45 PM2/13/21
to TiddlyWiki
I'm trying to run TiddlyWiki in node.js, behind Nginx such that I can spin up various wikis, all accessible by appending the name of the wiki to the end of the URL.
  • My test install is using Debian 10.8, Nginx 1.14.2-2+deb10u3, TiddlyWiki 5.1.23.
  • I'm running my testwiki from /var/www/html, as www-data:www-data.
  • I've created a unit file for it to run from systemd.
    • It is basically set to start as follows:  node /usr/local/bin/tiddlywiki testwiki --listen host=192.168.1.212 port=8080
I've used the following links for information:
I've even tried looking at different posts in this group but either my setup is not like what I'm reading about, or the fixes for others are just not working for me.

I seem to have no problem running the wiki on it's own.  It is accessible via port 8080, and works as expected.  However, when I try to put it behind Nginx, I can access it over port 80, but I immediately get 3 errors from syncer-browser-tiddlyweb:
  • XMLHttpRequest error code: 404
  • Error retrieving skinny tiddler list: XMLHttpRequest error code: 404
  • Sync error while processing save of '$:/StoryList': XMLHttpRequest error code: 404
Right now, my Nginx site file looks like this:

server {
       listen 80;
       listen [::]:80;

       server_name _;

       root /var/www/html;
       index index.html;

       location /testwiki/ {
               try_files $uri $uri/ @proxy =404;
               proxy_pass "http://192.168.1.212:8080/";
               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;
       }
}

I've changed this often while troubleshooting. I've just stuck with this configuration because I'm not longer seeing errors in the Nginx logs, so I'm starting to think Nginx is not the problem, but maybe the way I'm running the tw.

Any help would be greatly appreciated.

Petri M.

unread,
Feb 15, 2021, 4:19:20 AM2/15/21
to TiddlyWiki
Hi,

I think your "host" command might be wrong when starting the wiki. See here https://tiddlywiki.com/static/WebServer%2520Parameter%253A%2520host.html. For instance, I have a Docker + Caddy setup and I am starting the wiki with "host=0.0.0.0" command.

-Petri

Charles Anderson

unread,
Feb 17, 2021, 5:19:40 PM2/17/21
to TiddlyWiki
Honestly, I didn't know 0.0.0.0 could be used.  I did try changing my startup command, but it didn't change the errors I get.  Thanks for the info, though.

Charles Anderson

unread,
Feb 17, 2021, 5:28:25 PM2/17/21
to TiddlyWiki
Also, in the Nginx logs I see the following:

2021/02/17 14:22:32 [error] 4740#4740: *9 open() "/var/www/html/status" failed (2: No such file or directory)
2021/02/17 14:22:32 [error] 4740#4740: *13 open() "/var/www/html/recipes/undefined/tiddlers.json" failed (2: No such file or directory)

I can definitely say there are no "status" or "recipies" directories or files in /var/www/html, so this seems like the obvious reason for the 400 errors, but why are they being looked for?

Joshua Fontany

unread,
Feb 17, 2021, 7:00:00 PM2/17/21
to TiddlyWiki
The TiddlyWeb syncadaptor plugin calls those URLs to interact with the node server. The node server loads tiddlers marked as "module-type: route" and maps them as handlers to those urls. The browser should be calling "/var/www/html/recipes/default/tiddlers.json" in order to get handled. If your wiki is loading, but the calls to "/status", etc are not getting back to the node server, then I'm not sure where the block would be.

Hope that helps,
Joshua Fontany

Petri M.

unread,
Feb 18, 2021, 3:00:59 AM2/18/21
to TiddlyWiki
Hi,

Is your tiddlywiki initialised in the /usr/local/bin/tiddlywiki/ folder OR is it at /usr/local/bin/tiddlywik/testwiki/? The first case is not correct, so check this. Also you should double check that the wiki actually works from local network before trying to get nginx in the mix. If it is running on a vps or somewhere where you do not have local connection to then use the host=0.0.0.0 command so you can connect to it via vps_ip:port from your own computer.

-Petri

Charles Anderson

unread,
Feb 18, 2021, 5:24:34 PM2/18/21
to TiddlyWiki
I'm not sure what you mean by initialised.  I did re-install nodejs from the Node.js repository and am now running node v15.9.0/npm v7.5.4, and I installed Tiddlywiki via the directions given at tiddlywiki.com, with the global flag.  tiddlywiki is installed in /usr/bin.  My testwiki is still installed in /var/www/html and is owned by, and runs as www-data:www-data.  I have it configured to start with the host IP:8080, so that it's not open to everywhere, and Nginx is running on the same server.  It doesn't seem like the host should need to be set to 0.0.0.0.  I am able access the wiki at the host IP:8080, and it seems to work fine.  It's only when I try to access it through Nginx where it throws all the 400s.

Petri M.

unread,
Feb 19, 2021, 6:25:27 AM2/19/21
to TiddlyWiki
This 192.168.1.212 is the IP of the server where the nginx and TW are running? The thing is that the docs say that the "host" parameter is "...host is the IP address on which the server listens" and " n.n.n.n - listens for connections on the network interface with the specified IP address". Afaik usually this is just 127.0.0.1 if you are connecting from the same computer and it should be the same 127.0.0.1 in nginx as well. Though I don't know, I guess it does not make a difference.

Though I am curious about the try_files $uri $uri/ @proxy =404; command you have there. I do not know about nginx but are you sure you need this? What is this @proxy? You might want to take a peek at how that works. 

-Petri

eirich

unread,
Feb 19, 2021, 10:03:46 AM2/19/21
to tiddl...@googlegroups.com
Yep, the 212 IP belongs to the server where I have Nginx and TiddlyWiki installed, so that's why I set the same IP in the host parameter.  The server is headless, so with this configuration I can access the web page from any other computer on the same network.  As for the "try_files $uri $uri/ @proxy =404;" line, I think I picked this up from one of the various pages I used to research the configuration.  According to the default nginx file the, concerning "try_files" line:  First attempt to serve request as file, then as directory, then fall back to displaying a 404.  @proxy was a later addition. 

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/SyQq-Xr8TR4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/22fd3dca-b972-4e73-9ca9-26b3bafcc49an%40googlegroups.com.

Joshua Fontany

unread,
Feb 20, 2021, 7:06:26 PM2/20/21
to TiddlyWiki
Are you serving a single-file *.html wiki, or are you serving a folder with a `tiddlywiki.info` wiki-definition file, and a "tiddlers/" folder full of plain-text tiddlers ("node version")?

Best,
Joshua Fontany

eirich

unread,
Feb 22, 2021, 9:46:16 AM2/22/21
to tiddl...@googlegroups.com
I'm doing the 2nd method, folder with tiddlywiki.info and tiddlers folder.

Reply all
Reply to author
Forward
0 new messages