Hosting a Website via IPFS for Free!

Experimenting with IPFS (interplanetary file system) and wanted to demonstrate just how simple it is to host a website without using any hosting providers. IPFS allows users to access files via unique hashes in a P2P (peer-to-peer) fashion with or without the Internet. It’s quite marvelous :)

Let’s build and host a simple “hack the planet” website in 3 quick steps:

  1. Open a command line, run the IPFS daemon, and type:

As you can see from the output above, you now have an IPFS hash to your webpage that can be accessed directly from your filesystem from anywhere in the world (as long as they know your IPFS hash.

For fun, you can type ipfs cat QmUnnyJyYXiEXZ8eJ21ktzpyRdPhJ1918GmE2JGCmx815D and you will see the following code returned: <html><body>hack the planet</body></html>

2. Let’s view your file in real-time from the IPFS gateway via a web browser. Simply add your new hash to the end of like this:

3. Pick a web domain and update your forwarding preferences to the IPFS gateway URL above like this:

Now visit your domain! Note, you may need to allow a little time for your DNS to propagate. You are essentially serving your new webpage from your localhost via P2P through the IPFS gateway. You could just as easily interact with that web page directly without going through the IPFS gateway by directing your browser to:

Here’s a video that walks you through the hands-on tutorial:

Enjoy :)