Header image

CloudFlare has introduced a new gateway that allows you to easily access content stored on IPFS, or the InterPlanetary File System, through a web browser and without having to install a client.

With this announcement, CloudFlare also explains how you can use their gateway to create static web sites that are served entirely over IPFS. This allows users to create web sites containing information that cannot be censored by governments, companies, or other organizations.

What is IPFS

IPFS is a peer-to-peer or distributed file system that allow you to share files that will also be distributed to other computers, or nodes, throughout the networked file system. This makes it difficult to take down content stored on IPFS because even if one node is removed, the content will still be available from other nodes.

To use IPFS, users need to download a client for Linux, Mac, or Windows. Once downloaded, users can then use the command line client to store and retrieve files from the distributed IPFS file system.

To store a file on IPFS, a user simply uses the ipfs add [filename] command. For example, to store a file called README.md, you would enter ipfs add README.md. The file will then be uploaded to IPFS and be given a SHA256 hash, which is used to identify the file on IPFS.

For example. in the image below we stored the README.md file in IPFS and received a hash of  QmVh1g359Sb2YNmegSxSRp5paktWGVLQMwtgYBx1haqwjA that is now associated with this file.

File added to IPFS
File added to IPFS

In the future, if anyone wants to access that file, they can simply start their IPFS client, but this time use the ipfs get [hash] command. For example, to download the README.md file previously stored on IPFS, the user would use the ipfs get QmVh1g359Sb2YNmegSxSRp5paktWGVLQMwtgYBx1haqwjA command as shown below.

Get file from IPFS
Get file from IPFS

By using CloudFlare's IPFS gateway, though, it is not necessary to download a client to access data stored on IPFS. Users can simply use the https://cloudflare-ipfs.com/ipfs/ URL and the file's hash to access it via a web browser.

Using CloudFlare's IPFS Gateway to access files stored in IPFS

With CloudFlare's IPFS Gateway, it is very easy to access files stored in IPFS using any web browser. To open a file stored on IPFS you would simply connect to the web address https://cloudflare-ipfs.com/ipfs/[hash] URL, where hash is the hash of the file stored on IPFS.

For example, if we wanted to view the README.me file we stored earlier under the hash QmVh1g359Sb2YNmegSxSRp5paktWGVLQMwtgYBx1haqwjA, we can now browse to https://cloudflare-ipfs.com/ipfs/QmVh1g359Sb2YNmegSxSRp5paktWGVLQMwtgYBx1haqwjA

File stored on IPFS
File stored on IPFS

It's now simple to create websites stored on IPFS

While IPFS Gateway's are not new, CloudFlare is trying to make it easy for users to create distributed web sites using IPFS by offering free SSL certificates and an easy to use method to connect a domain to IPFS.

If you own a domain and want to connect it to content stored on IPFS, you can configure CNAME and TXT DNS records that allow CloudFlare's IPFS gateway to serve content through it.

Before you get started, though, it is important to understand how store your content in such a way that it will not be removed over time.

"Before we get into how to do that, it’s important to understand what it means to add content to IPFS," explains CloudFlare's support article on making IPFS websites. "When content is uploaded to the IPFS network, it only stays available to the network as long as some node, somehwere in the world, chooses to host it. If you want to make sure the content you uploaded stays on the network, you have to make a choice. You can either pay a service to upload the content and keep it there as long as you pay your bill, or you can run your own IPFS node."

Once your content is uploaded to IPFS, you can then create a CNAME and TXT record that connects your domain to your stored IPFS content by performing the steps below.

First, go to the DNS settings for your domain. When you’re there, add the following two records:

  1. CNAME from your.website to www.cloudflare-ipfs.com
  2. TXT record from _dnslink.your.website to dnslink=/ipfs/[your_hash_here]

Now any request to your.website will resolve to cloudflare-ipfs.com/ipfs/[your_hash_here].

For more details on how to use CloudFlare's IPFS Gateway to serve a static website, you can use this support article from CloudFlare.

Related Articles:

Phishing Attacks Distributed Through CloudFlare's IPFS Gateway

Cloudflare Becomes a Registrar, Sells Domains At Cost

Cloudflare Ends CAPTCHAs for Tor Users While Blocking Bad Actors

Cloudflare Makes DNSSEC Activation Easy