How to make a CDN using IPFS

(I was actually about to post this under The Gallery until I saw that this category existed)

How to make a CDN using IPFS


Note: You might not want to do this on Glitch, because, well projects sleep after 5m (without boosted) and also this could be considered abusing the platform.

Things you’ll need:

  • Go-IPFS
    Edit: js-ipfs can also work! npm install -g ipfs. It does compile stuff using node-gyp tho.
  • 1+ computers with Go-IPFS installed.

Directions:

Setup the First Server:

  1. Run ipfs daemon to start the IPFS daemon. If you skip this step, the following directions will fail to work.
  2. Change Directions (cd) to the folder where your file/folder is located at.
  3. Type the command ipfs add [File/Folder Name]. The response you get should look something like this.
QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG
// This is called a hash.
  1. Take that response (hash) and then run ipfs pin [HASH].
  2. Now that you got the file on the network, go to the other servers and run ipfs pin [HASH].
  3. Now, try the to access the file using the gateway. Open a web browser go to: https://gateway.ipfs.io/ipfs/[HASH].

Tips:

I’ll be making more IPFS tutorials soon! Such as replacing a hash with a domain, etc


Learn more about IPFS and how it works here!

8 Likes

It looks like you spelled gateway wrong at the beginning. It says gataway.

Thanks

You should put this on DEV.to.

Already started the draft. I just have to finish it

This is good, just want to give a few pointers.

  1. You should disclose that if you want to do this, your IP is going to be made public.
  2. You should make the pinata work.

What do you mean by that?
Edit: nvm, I added https://, thanks!

2 Likes

I also recommend saying that there is a snap package for this. Do sudo snap install ifps. It worked better than Node.js.

Yes, there is a snap package, but I added the NPM way because armv6l isn’t supported.

I also noticed that once it is loaded once, it is loaded forever. I had to basic use curl to get all the files to work. But, there are still some loads. This is a video that I upload. And it is like using 3G on YT today.

But even then, the most I could milk out was 28 seconds.

What is the hash of the video?

QmUw2nER4NVv2bSzPNFd2kAL756QyQyzmZmYpw1L1HPs8W

Where did you download this from?

What do you mean?

Never mind. Maybe it got corrupted?

So, I was able to load it. Ima restart my machine to see if that helps. My console is bricked. So as of rn, best I can do is hope that my machine is not corrupted. Everything else on it works. The commands just have no response.

Yeah, it just stopped at 28 seconds.

Booting up.

I was able to get the whole video. You?