Going Interplanetary

I have already complained about how hard it is to properly do Indieweb in IPFS, yet I still couldn’t help wishing I had this website in IPFS. A website that is on IPFS is always available (although it may be slow to load the first time) as long as the DNS record is there and at least one copy exists online (which is why such a website can only be blocked at the DNS level). The more popular a given page is, the more copies of it exist, and the faster it loads — a “free” CDN of sorts. It’s also good for visitors’ privacy: not even the server’s logs have any traces of visits. I actually do have a “business-card page” that only exists on IPFS (and is accessible from the “normal” web by means of a free Cloudflare service) and is doing alright. If only the propagation speed wasn’t an issue (and it is a huge issue when sending a webmention)…

The obvious solution came to my mind only recently: instead of moving the website to IPFS completely why not mirror it onto IPFS and provide a DNS record?! The website itself isn’t going anywhere from the “normal” Web, so webmentions and all the Indieweb stuff continues to work, but the website is also accessible via IPFS with all the benefits. It isn’t even that hard to do…

Since my website now runs on a VPS anyway and the server has some power to spare, it was easiest to install an IPFS node right onto this very server and add literarily a couple of lines to the script that rebuilds the website on changes. Having a moment during the update when directories with both the new and the old versions of the website exist helped a lot; I can easily “un-pin” the old version and make the new one available on IPFS. Somewhat like:

ipfs add -r -H -Q -n old/public | ipfs pin rm
ipfs-dns.sh $(ipfs add -r -H -Q public)

Here the ID of the new version of the website is passed to the ipfs-dns.sh script that puts it into the DNS record. My VPS being on DigitalOcean it looks something like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#!/bin/sh
set -e
token=[auth token]
record=[the number of the TXT record that contains _dnslink]
curl -X PUT \
 "https://api.digitalocean.com/v2/domains/evgenykuznetsov.org/records/$record" \
 -H "Authorization: Bearer $token" \
 -H "Content-Type: application/json" \
 -d '{"data":"dnslink=/ipfs/'$1'"}' \
 -s | jq '."domain_record"."data"'

I did implement all that today. Now if you visit this website with an IPFS-aware browser (there are plugins for Firefox and Chrome, and I’m told that Brave has it out of the box), the website will be opened via IPFS.

Great, right?!