Appearance
In the instructions below I'll asume your home server has the domain nas.local
, replace it with your IP or corresponding domain as appropriate.
Installing IPFS service through docker ​
The most convenient, safe and reproducible way to install IPFS in a NAS or home server would be doing it within a container.
Below an example command for docker using the linuxserver.io image, adapt it to your needs.
sh
docker run -d --name=ipfs \
-p 8111:80 \
-p 4001:4001 \
-p 5002:5001 \
-p 8112:8080 \
-e PUID=1026 \
-e PGID=100 \
-e TZ=Europe/Berlin \
-e IPFS_PROFILE=lowpower \
-v ./config:/config \
--restart unless-stopped \
ghcr.io/linuxserver/ipfs
...or if you use docker-compose, set up a yaml file like this:
yaml
version: "3.3"
services:
ipfs:
container_name: ipfs
image: ghcr.io/linuxserver/ipfs:latest
volumes:
- "./config:/config"
environment:
- PUID=1026
- PGID=100
- TZ=Europe/Berlin
- IPFS_PROFILE=lowpower
ports:
- "4001:4001"
- "5002:5001"
- "8112:8080"
restart: unless-stopped
IPFS Web UI Dashboard ​
Once the container is running, you can open in your browser the address http://nas.local:5002/webui/.
You should see the Web UI for IPFS, and because you are accesing it through the API port no further configuration would be necessary to use this UI (unlike the 443 port).
IPFS Gateway for browser access ​
IPFS also runs a local gateway that allows accessing any CID content through an HTTP interface.
The gateway is run in the container at the port 8080, which in our example was redirected to 8112.
You can test the IPFS local gateway accessing http://nas.local:8112/ipfs/bafkqae2xmvwgg33nmuqhi3zajfiemuzahiwss. You should see the words "Welcome to IPFS 😃".
Setting up the command-line IPFS utility ​
IPFS offers a commandline tool that can be very conveniento to download or upload content to/from the node, or query IPFS items in general.
Once you install the tool, to configure it to work using the node from our network, you'll need to write the line http://nas.local:5002
(or alternativelly /ip4/YourServerIPAddressHere/tcp/5002
) into its API configuration file (Linux this would be in ~/.ipfs/api
, for Windows %HOMEPATH%/.ipfs/api
).
sh
mkdir ~/.ipfs
echo 'http://nas.local:5002' >~/.ipfs/api
To have the ìpfs
command line program work.... create file $HOME/.ipfs/api with content "/ip4/127.0.0.1/tcp/5002"
Just for reference, below some examples on how to use the cli tool:
sh
# Output a CID to the terminal
ipfs cat bafkqae2xmvwgg33nmuqhi3zajfiemuzahiwss
# Download a CID to a file on disk
ipfs get bafkqae2xmvwgg33nmuqhi3zajfiemuzahiwss -o test.txt
# Create a folder in the internal MFS (mutable file system)
ipfs files mkdir /new-folder
# List the contents of the root of the MFS
ipfs files ls /
# Check the ipfs CID and details on a file or directory from the MFS
ipfs files stat /new-folder
# Upload a new folder for sharing and reference it in the MFS (as "/new-folder/uploads")
ipfs add -wr ./uploads/ --to-files /new-folder/
# Pin a CID so it doesn't get garbage collected
ipfs pin add bafkqae2xmvwgg33nmuqhi3zajfiemuzahiwss
# List objects pinned
ipfs pin ls
# Remove pinned object
ipfs pin rm bafkqae2xmvwgg33nmuqhi3zajfiemuzahiwss
"IPFS Companion" on the browser ​
IPFS offers the "IPFS Companion" browser extension to access ipfs urls from the browser without having to manually input http://nas.local:8112/ipfs/<cid>
every time.
This one is more troublesome. In theory you could just provide the address to your local gateway in the configuration and have it use it. But many versions of the extensions won't allow you to do this due to securityx concerns (in fear of someone sniffing in your network who could intercept the requests).
This could be circumvented using ssh tunneling is you have ssh access to your server, so the remote port is redirected to http://localhost:8112
which would be affected as a safe address, being local. This could be done as below:
sh
ssh -L 5002:localhost:5001 -L 8112:localhost:8112 -N nas.local
Alternativelly, a safer but more troublesome way to do it would be setting up a reverse proxy on the machine with nginx that serves HTTPS using a self-signed certificate or a custom CA, this way we could use https://nas.local
and have it be accepted by IPFS companion.