Bring You to IPFS

Last post, I use Hexo with Minos to build a full site multi-language blog, it’s exciting! So in this post, I will tell you how to bring the new blog to IPFS.

What is IPFS

IPFS is called for short of InterPlanetary FileSystem, maybe you can visit your data from another galaxy. Due to the limit speed of light, we need quantum entanglement communication to play well.

IPFS uses data hash address instead of website domain, but in the next, you will find if you want to visit your data in IPFS within a traditional website, you still need domain. And to get hash data, you have to visit a IPFS node server. So, want to decentralize, you maybe need a centralized server first.

Meanwhile, distributed data storage will cause waste. Some updated files, previous versions are no longer valid, but are pinned and permanently retained inside IPFS and cannot be deleted. Even the owner has forgotten the previous data hash, the dead files become ghosts in the IPFS system.

Install IPFS

  • Download latest release
    • Open Official Site, click Download IPFS for your platform
    • Choose the binary for your platform, download and unzip
  • Install IPFS package
    • Such as MacOS, enter go-ipfs, and execute ./install.sh
    • If permission denied, add sudo, then copy the ipfs file into path
    • Execute ipfs help to test installed
  • Initialize the node

    • Execute ipfs init, init the folder .ipfs and create config files

    • Keep the peer identity, or find it in ~/.ipfs/config

    • Modify config file, set the storage space vi ~/.ipfs/config

      "Datastore": {
        "StorageMax": "6GB"
      }
  • Start the daemon
    • Execute ipfs daemon > ipfs.log &, start daemon as background process
    • Execute ps ax|grep ipfs, check the daemon alive

Publish to IPFS

  • Name publish

    • Execute below, bind node name with public folder hash

      ipfs name publish QmUmVuqD8RdLjeuqKZC8dAaKkcRedPsGtDFbwPyKrR278K

    • Bind success, the name is the peer when node init

      Published to Qmdn4vrHjbmsQvHPXAiJvWFHQRqGd5fP33HJqd9AE4EjMH: /ipfs/QmUmVuqD8RdLjeuqKZC8dAaKkcRedPsGtDFbwPyKrR278K

      Visit https://ipfs.io/ipns/Qmdn4vrHjbmsQvHPXAiJvWFHQRqGd5fP33HJqd9AE4EjMH namely

    • Note: name is fixed, hash is changed, so bind name just like stable IP address

Config domain

  • Register domain
    Just go Godaddy or other domainer
  • Change DNS Server
    Now, please use CloudFlare, for some reason:

    • Free DNS
    • Free https, dynamic and security
    • Free IPFS gateway

    Please set DNS Server as

    dahlia.ns.cloudflare.com
    sid.ns.cloudflare.com

  • Add DNS record

    • DNS, add CNAME record, set as cloudflare-ipfs.com

    • DNS, add TXT record _dnslink, use ipfs node name

      dnslink=/ipns/Qmdn4vrHjbmsQvHPXAiJvWFHQRqGd5fP33HJqd9AE4EjMH

    • Apply ssl certificate
      input your domain

  • Wait for DNS effect

Setup Gateway

If you want to build your own gateway, go on (not necessary)

  • Install Nginx
    • apt install nginx-full
  • Config Nginx
    • vi /etc/nginx/sites-available/example_com
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      upstream ipfs-server {
      server 127.0.0.1:8080;
      }

      map $http_upgrade $connection_upgrade {
      default upgrade;
      '' close;
      }

      server {
      listen 80;
      server_name example.com;

      location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://ipfs-server/;
      }
      }
    • execute nsite -e service nginx reload

User Experience

This site’s cloning uses the IPFS, you can try.

The actual feeling, is different from we thought before. The first open takes a long time, always 504 timeout, but once connection is success, open will be very quick. Why? The IPFS official admits this is caused by the IPNS service bugs. We published name in the past, so we don’t need modify DNS while change files.

However, ipns service is very time-consuming and takes more than 20 seconds often. Meanwhile, ipfs is almost second. IPFS Officle website content is fixed, so hash address doesn’t change, using ipfs and open fast.

If, IPFS cannot enhance the speed of ipns service, first open meets 504 always, who can wait?

Use iTerm2 to telnet SMTH bbs Hexo multi-language with Minos

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×