Introduction to IPFS: Run Nodes on Your Network, with HTTP Gateways

How to install IPFS nodes across your VPS network and configure your own Gateways

IPFS Gateways

Available Gateways

Onto IPFS

Installing IPFS

Option 1: Installing Manually

cd ~
wget https://dist.ipfs.io/go-ipfs/v0.4.18/go-ipfs_v0.4.18_linux-amd64.tar.gz
tar xvfz go-ipfs_v0.4.18_linux-amd64.tar.gzcd go-ipfssudo ./install.shipfs help

Option 2: Install using ipfs-update

cd ~
wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-amd64.tar.gz
tar xvfz ipfs-update_v1.5.2_linux-amd64.tar.gzcd ipfs-updatesudo ./install.shipfs-update versionsipfs-update install latest

Initialising IPFS

Mounting a Block Storage Volume

mkdir /mnt/<name_of_your_volume>/.ipfs
export IPFS_PATH=/mnt/<name_of_your_volume>/.ipfs
ipfs init --profile server
ipfs config showorless /mnt/<name_of_your_volume>/.ipfs/config

Opening required firewall ports

sudo firewall-cmd --zone=public --add-port=4001/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo systemctl reload firewalldsudo firewall-cmd --zone=public --permanent --list-ports

Running IPFS in the Background

Setting up IPFS Daemon as Supervisord Process

easy_install supervisororpip install supervisor
sudo echo_supervisord_conf > /etc/supervisord.conf
sudo supervisord
sudo vi /etc/supervisord.conf[program:ipfs]
environment=IPFS_PATH=/mnt/<name_of_volume>/.ipfs
command=ipfs daemon
sudo supervisorctl reread && sudo supervisorctl update
sudo supervisorctl status
sudo supervisorctl stop ipfs

Configure Your IPFS HTTP Gateway

"Datastore": {
"StorageMax": "1GB"
}
#change this
"Gateway": "/ip4/127.0.0.1/tcp/8080"
#to this
"Gateway": "/ip4/0.0.0.0/tcp/8080"
"HTTPHeaders": {
"Access-Control-Allow-Headers": [
"X-Requested-With",
"Access-Control-Expose-Headers",
"Range"
],
"Access-Control-Expose-Headers": [
"Location",
"Ipfs-Hash"
],
"Access-Control-Allow-Methods": [
"POST",
"GET"
],
"Access-Control-Allow-Origin": [
"*"
],
"X-Special-Header": [
"Access-Control-Expose-Headers: Ipfs-Hash"
]

},
"RootRedirect": "",
"Writable": true,
"PathPrefixes": [],
"APICommands": []
http://<your_ip_address>:8080/ipfs/QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ/cat.jpg

Connecting your Nodes as Peers

ipfs swarm peers
ipfs swarm connect <address>
/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
ipfs swarm disconnect <address>

Conclusion

Programmer and Author. Director @ JKRBInvestments.com. Creator of LearnChineseGrammar.com for iOS and Android.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store