Tiddlywiki Nginx and WebDav oh my

I keep all my wikis on a virtual private server ( I use a frantech paid server and I am experimenting and am so far very happy with oracle cloud’s free tier ) and I recently discovered that the nginx web server has a webdav plugin. This allows me to specify a directory as a webdav server to put tiddlywikis in which then auto save because of tw’s default webdav behavior.

For a full length explanation I wrote a blog post, but here is the tldr if you’re familiar with nginx :

install nginx and modules: sudo apt update && sudo apt install sudo apt -y install nginx nginx-extras libnginx-mod-http-dav-ext apache2-utils (this includes the apache utils for basic authorization). Then add block to server config

       location /private {
               dav_methods PUT DELETE MKCOL COPY MOVE;
               dav_ext_methods PROPFIND OPTIONS;
               dav_access user:rw group:rw;

               client_max_body_size 0;
               create_full_put_path on;
               client_body_temp_path /tmp/;

               autoindex on;

               auth_basic "Enter Credentials Fool";
               auth_basic_user_file /etc/nginx/.htpasswd;
    }

Add yourself to the www-data group: sudo adduser -aG www-data <user> and verify permissions and ownership of the directories: sudo chown -R <user>:www-data wikidirectory/ and sudo chmod -R 775 wikidirectory/ ( thank you to @pmario for pointing out these security issues! ).

Now you can log into that directory and your wikis will autosave! Also you have an easy way to upload files via a webdav client.

Finally for a public facing version just create a symlink: sudo ln -sn /var/www/html/private/wiki1.html /var/www/html/public/wiki1.html

I have been using the tw-reciever plugin for a while now but given the added convenience of having a webdav client connection I’m transitioning to this for all my single file wikis.

update: changes to address security issues as pointed out by @pmario

1 Like

In case anyone finds it useful, here is the docker image some of my colleagues are using for nginx+webdav for TW: https://github.com/dgraziotin/docker-nginx-webdav-nononsense

There are some nice ideas in there for a smooth WebDAV setup even for someone not using Docker.

@digitalap3 you may find the FileUploads plugin and the experimental PUT uploader for it of interest, it works with WebDAV. Available via this plugin library.

3 Likes

I absolutely prefer using Docker for anything like this that faces the public web and this is a great resource, thank you! I will update my post to direct people there.

Oh man I am really excited to play with this thank you.

Are you sure all:rw is a good idea in general? Even if there is an .htpasswd file. If something is configured in the wrong way, your server has “world” access. … I’d say: Have fun!

1 Like

Ah permissions, a source of never ending FUN in Linux. Thanks for pointing this out. I am testing now and will report back later with changes.