node.js - Full Function Via 127.0.0.1 and Read-only Via Other IP

143 views
Skip to first unread message

Kevin Kleinfelter

unread,
Sep 20, 2017, 2:28:25 PM9/20/17
to TiddlyWiki
It would be real handy if *I* could edit my node.js TW, share links to it, and block the sharers from updating.  I understand that I can export the site as HTML and publish that HTML file, but I've got lots of images.  99.9% of the time, I only need to say to someone, "Here's a permalink.  Read this one story for your answer."

The use-case is that I have lots of reference material, my job involves solving people's technical problems, and I'd like to send them a pointer to my canned solution.

I'm wondering how I might set things up so that when accessed via 127.0.0.1, full functionality is available, but when accessed via other IP, it is read-only.

If I were running this on Linux, I'd use umask and file permissions and run a second node.js as the nobody user.  I'm running node.js as a Windows service, and it is in an Active Directory environment, where creating a new user-ID takes an act of congress.

I *could* just set up a daily file copy, replicate my whole TW to a second folder, and let the "public" trash the disposable copy.  I'd prefer not to go that route.

Any clever ideas for a read-only instance using the same data?
Message has been deleted

Jed Carty

unread,
Sep 23, 2017, 5:33:17 AM9/23/17
to TiddlyWiki
You could probably add this into the tiddlywiki code to make downloading the only way to save unless you are on localhost.

Using something like the ip module in node should make this pretty simple but I am not certain where in saver-handler.js the change needs to be done or if it needs to be somewhere else.

RichardWilliamSmith

unread,
Sep 23, 2017, 10:14:09 AM9/23/17
to TiddlyWiki
Why not publish it as a static site for other people to look at? It will load much quicker for them. I wrote instructions for a custom site here: https://www.didaxy.com/exporting-static-sites-from-tiddlywiki but if you're happy with the default styling, you really only need the default commands: http://tiddlywiki.com/static/Generating%2520Static%2520Sites%2520with%2520TiddlyWiki.html

Arlen Beiler

unread,
Sep 24, 2017, 8:24:24 AM9/24/17
to TiddlyWiki
I'm pretty sure it is possible to listen on more than one IP address separately if they are on different interfaces, such as in this case. I will keep it in mind for Tiddly server, but for vanilla node tw5, you can load two instances, but changes won't show up until you reload the read-only instance. 

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b7c93ca0-8ded-4005-a2ea-9dfd0fc4c379%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Lauber

unread,
Sep 25, 2017, 8:52:09 AM9/25/17
to TiddlyWiki
What I did was put my wiki behind a nginx LB with this config.  This says READ requests (GET, HEAD) are permitted by anyone, but POST and other requests require user authentication.  

server {
 listen
80;
 access_log
/var/log/nginx/tiddlywiki.access.log combined;
 
 location
/ {
     root
/opt/html;
     index index
.html index.htm;
 
}
 
 location
/wiki/ {
     limit_except GET HEAD
{
         auth_basic
'Restricted';
         auth_basic_user_file
/etc/nginx/auth/tiddlywiki;
     
}
     proxy_pass http
://127.0.0.1:8888/;
     proxy_set_header
Host $host;
     proxy_set_header X
-Real-IP $remote_addr;
     proxy_set_header X
-Forwarded-For $proxy_add_x_forwarded_for;
     
}
 
}
Reply all
Reply to author
Forward
0 new messages