node.js Tiddlywiki Doesn't Include custom proxy port over ssh when port forwarding?

177 views
Skip to first unread message

leeand00

unread,
Jun 16, 2020, 3:57:23 PM6/16/20
to TiddlyWiki
I just installed TW 5.1.22 on a machine (the TW5 server) that I have on the DMZ behind an SSH gateway. 

I have ssh port forwarded from outside and used the local port 8080 to tunnel through the SSH gateway to my TW5 server inside.

I also have another PHP web application on there that seems to be working fine (it doesn't appear to use much in the way of ajax).

(both of these web applications sit behind nginx, which handles the requests)

On the remote machine I'm using to connect, in the /etc/hosts files I've added the lines `wiki.somedomain.com 127.0.0.1` and `kanboard.somedomain.com 127.0.0.1`.

I access them from a remote machine in the browser using `http://wiki.somedomain.com:8080/` and `http://kanboard.somedomain.com:8080/`

Tiddlywiki does not appear to work correctly, because although the initial page loads just fine, any subsequent ajax requests back to the server do not include the 8080 and instead they just use :80, and thus I can browse the wiki, but I can't make changes.

Is there any way I can filter the text for these requests, or change a setting in the tiddlywiki server, so that I can include the local port in my requests made via ssh port forwarding?

Thank you,
   Andrew J. Leer


leeand00

unread,
Jun 16, 2020, 4:31:27 PM6/16/20
to TiddlyWiki
I read something about dynamic port forwarding (and then configuring your browser for that), is that maybe the solution?

leeand00

unread,
Jun 16, 2020, 9:29:46 PM6/16/20
to TiddlyWiki
It's not $:/info/url/port is it? 

I grepped the github repo I pulled it from and it says Port portion of URL of wiki (eg, ''<<example port>>'') in the InfoMechanisms tiddler.

On Tuesday, 16 June 2020 15:57:23 UTC-4, leeand00 wrote:

Saq Imtiaz

unread,
Jun 17, 2020, 2:41:44 AM6/17/20
to TiddlyWiki
Look at $:/plugins/tiddlywiki/tiddlyweb/ServerControlPanel

$protocol is replaced with document.location.protocol
$host is replaced with document.location.host

I think the value you want to set is: $protocol//127.0.0.1:8080

PMario

unread,
Jun 17, 2020, 2:43:19 AM6/17/20
to TiddlyWiki
Hi
I think you should forward URL paths to specific ports, if more than 1 TW server is active. see: https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ or also see this discussion: https://groups.google.com/forum/#!searchin/tiddlywiki/nginx$20proxy|sort:date/tiddlywiki/StoO3ApsWJU/SADaAl3hBwAJ

-m

leeand00

unread,
Jun 17, 2020, 1:40:09 PM6/17/20
to tiddl...@googlegroups.com
PMario, yes, I'm already using nginx to shoot multiple wiki's across port 80 inside the DMZ, and I access it from a specific machine on the LAN that way (as you stated using a reverse-proxy).

I'll look at the discussion though; maybe I set it up wrong.

leeand00

unread,
Jun 17, 2020, 1:57:24 PM6/17/20
to TiddlyWiki
The tiddler in question doesn't exist; I'm running version 5.1.22, should I create the tiddler?

Also there's a special tiddler $__config_tiddlyweb_host.tid I had to modify it to get it to work with the nginx reverse_proxy.

I just attempted to add :8080 to it, maybe that will fix it up; did they change the tiddler name in a new version?

I'll let you know what I find.

Saq Imtiaz

unread,
Jun 17, 2020, 2:06:38 PM6/17/20
to TiddlyWiki
In the Control Panel, which plugins do you see listed?

Do you see either tiddlyweb or nwsaver?

leeand00

unread,
Jun 17, 2020, 2:20:11 PM6/17/20
to TiddlyWiki
The plugins I have are:

- Core: TiddlyWiki5 core
- Filesystem: Synchronise changes to the local filesystem
- Highlight: Highlight.js syntax highlighting
- TiddlyWeb: Sync changes to TW5 server or TiddlyWeb server

After making the changes I mentioned in my previous post; It works remotely! :)  But now it's stopped working locally...I get the same error I did remotely before.  I think it's because tiddlywiki is expecting 8080 and nginx is running on port 80, so when the port is forwarded it can use 8080, but when it is not, tiddlywiki still thinks it's looking for port 8080 and I get the same errors I got before when tiddlywiki was expecting port 80.

Saq Imtiaz

unread,
Jun 17, 2020, 2:49:40 PM6/17/20
to TiddlyWiki
What is the current value of $__config_tiddlyweb_host.tid ?

Try changing it to: $protocol$//$host$
This should make it pickup the port from document.location.host

leeand00

unread,
Jun 17, 2020, 3:32:39 PM6/17/20
to TiddlyWiki

I tried that just now (except I added a forward-slash at the end. 

(All of these errors are from syncer-browser-tiddlyweb)

Now I get XMLHttpRequest error code: 404 (it's trying to pull /status) when I get that.

And I get Error retrieving skinny tiddler list: XMLHttpRequest error code 502 (isn't that "bad gateway"?)

And also Sync error while processing save of '$:/StoryList': XMLHttpRequest error code: 502

Saq Imtiaz

unread,
Jun 17, 2020, 3:35:08 PM6/17/20
to TiddlyWiki
In the browser developer console, check to see what URL the requests are being made to now.

Sorry it's a bit difficult to debug when I don't have the same setup.

leeand00

unread,
Jun 17, 2020, 4:47:42 PM6/17/20
to TiddlyWiki
No I'm just happy someone is here to help me out.  Thank you!

The URL requests for tiddlers.json?filter=[all[tidd... is being made to http://wiki/helpdeskaleer.com/recipes/undefined/tiddlers.json?filter=...URI Encoded string

That's one of the other wiki's that I have reverse proxied...also the initiator is `/:74 (xhr)`, is that a websocket or something?  And from that I get a 404 (since the recipes wiki isn't started).

The recipes wiki config is way up there towards the start of the config file on line 725 or so in the file and it looks like this:

location ^~ /recipes {
  access_log
./logs/recipes_access.log;
  error_log
./logs/reipes_error.log;
  proxy_buffers
16 4k;
  proxy_buffer_size
2k;
  proxy_set_header
Host $host;
  proxy_set_header X
-Real_IP $remote_addr;
  rewirte
/recipes(.*) /$1 break;
  proxy_pass http
://wiki.helpdeskaleer.com:9137;

}


on the other hand...much futher down the nginx config on line 1065 we have:

location ^~ /windows/wsus {
   access_log
./logs/wsus_access.log;
   error_log
./logs/wsus_error.log;
   proxy_buffers
16 4k;
   proxy_buffer_size
2k;
   proxy_set_header
Host $host;
   proxy_set_header X
-Real_IP $remote_addr;
   rewrite
/windows/wsus(.*) /$1 break;
   
# proxy_pass http://wiki.helpdeskaleer.com:9171;
   proxy_pass http
://localhost:9171;   # NOTE HERE IS WHERE I DECIDED THAT IT SHOULD JUST BE AVAILABLE FROM THE LOCAL HOST.

}

Saq Imtiaz

unread,
Jun 17, 2020, 5:29:37 PM6/17/20
to TiddlyWiki
To recap:

From the remote machine
- you access wiki via wiki.somedomain.com:8080
- locally you access wiki via 127.0.0.1, i.e. on port 80?
And the problem is that we need the tiddlyweb plugin to make requests to the same port as used in the browser URL. Am I understanding this correctly?
- What is the exact value of $__config_tiddlyweb_host.tid ?
- If you are editing this file on the file system, are you restarting the server after each edit?
- When you set the value to $protocol$//$host$/ and restart the server:
-- what is the URI for any errors you get from syncer-browser-tiddlyweb when accessed from the remote machine? What is the brower URL?
-- same as above but when accessed from the local machine?

leeand00

unread,
Jun 17, 2020, 7:30:12 PM6/17/20
to TiddlyWiki
Okay so I made a network diagram of sorts and attached it.

 I try to access the wiki both externally and internally, and depending on the value in $__config_tiddlyweb_host.tid different things work (internal / external), but they never both work (see the lower right for the settings I've tried).

Internally there are two hosts the SSH gateway and the actual tiddlywiki server.  One must do ssh forwarding locally to access it externally.  Internally, a firewall rule allows us to pass packets directly between the two subnets.

DMZ_Diagram.png



"- What is the exact value of $__config_tiddlyweb_host.tid ?"

I've listed several different values that I have tried and what they did above in the lower right portion of the diagram.

"- If you are editing this file on the file system, are you restarting the server after each edit?"

Yes, I do a `sudo systemctl stop tw5wsus; sudo systemctl start tw5wsus; sudo systemctl status tw5wsus`

I'll get back to you on your last two questions in a moment, I just wanted to add the diagram.
DMZ_Diagram.svg
DMZ_Diagram.png

leeand00

unread,
Jun 18, 2020, 11:13:31 AM6/18/20
to TiddlyWiki
Okay I think I figured it out.

So I have to set $__config_tiddlyweb_host.tid to http://wiki.helpdeskaleer.com:8080 and then regardless of if I'm inside or outside the network, I have to set my /etc/hosts to the host FQDN (internal to the network) with 127.0.0.1 on the client laptop and then do local port forwarding to the SSH gateway through to the host on port :8080.  Then in the browser I have to use http://wiki.helpdeskaleer.com:8080/windows/wsus and then as long as have both of those requirements setup on the laptop remote or local, I'll be able to access nginx/tiddlywiki.
Reply all
Reply to author
Forward
0 new messages