Guide to Configuring a VPS as a Web3 Decentralized IPFS Pinning Service for DApp Projects
Convert a VPS into a decentralized IPFS pinning service for DApp projects to ensure data resilience and access. This guide provides a detailed A-Z configuration process, including...
Image credit: Mohamed_hassan · Pixabay Content License
Converting a VPS into a decentralized IPFS pinning service for DApp projects is a crucial step to ensure data resilience and access to decentralized content. This guide provides a detailed, step-by-step configuration process from A to Z, covering IPFS installation, pinning service setup, security configuration, and performance optimization. The steps are optimized for NVMe VPS environments, ensuring fast and stable access for Web3 applications.
Requirements and Preparation
To deploy an IPFS pinning service on a VPS, you need a server with at least 2GB RAM, 1 CPU core, and 40GB SSD or NVMe storage. The VPS should run a Linux operating system (Ubuntu 22.04 or Debian 11). You must have SSH access to the server with root or sudo privileges. Ensure the VPS has a stable internet connection and no bandwidth limitations.
Prepare the server before starting:
- Log in to the VPS via SSH:
ssh root@your_vps_ip - Update the system:
apt update && apt upgrade -y - Set up the firewall:
ufw allow 22,80,443,5001,5002
Install and Configure IPFS
IPFS (InterPlanetary File System) is a decentralized protocol for storing and accessing data. To configure the VPS as a pinning service, you need to install the IPFS daemon.
Follow these steps:
curl -O https://ipfs.io/ipfs/QmXoypizjW3WknFiJnKLwHCnL72KsS15Dn8g8jW47514K9/go-ipfs/v0.11.0/go-ipfs_v0.11.0_linux-amd64.tar.gz
tar -xzf go-ipfs_v0.11.0_linux-amd64.tar.gz
cd go-ipfs
sudo ./install.sh
After installation, start the IPFS daemon:
ipfs init
ipfs daemon --enable-pubsub-experiment
Run the daemon to verify functionality. IPFS creates a configuration directory at ~/.ipfs. You can check the status using ipfs id.
Set Up the Pinning Service
To turn the VPS into a pinning service, configure IPFS to automatically store and update requested documents. Use the ipfs pin add command to begin pinning.
Follow these steps:
ipfs pin add QmXoypizjW3WknFiJnKLwHCnL72KsS15Dn8g8jW47514K9
ipfs pin add QmZ6q8jR9pYv4cZ4v4a4qjX7Y8k4JY9K8q4Q4Q4Q4Q4Q4
To automate the process, create a shell script to pin documents from a list. For example:
#!/bin/bash
# pin_list.txt
# QmXoypizjW3WknFiJnKLwHCnL72KsS15Dn8g8jW47514K9
# QmZ6q8jR9pYv4cZ4v4a4qjX7Y8k4JY9K8q4Q4Q4Q4Q4Q4
while read line; do
ipfs pin add "$line"
done < pin_list.txt
Run the script with bash pin_script.sh. You can schedule the script to run periodically using cron.
Optimize Performance and Security
To ensure performance and security, configure the following parameters in the ~/.ipfs/config file:
| Parameter | Value |
|---|---|
| Addresses.API | /ip4/0.0.0.0/tcp/5001 |
| Addresses.Gateway | /ip4/0.0.0.0/tcp/80 |
| Swarm.AddrFilters | [\"/ip4/192.168.0.0/16\"] |
| Bootstrap | [\"/ip4/10.0.0.1/tcp/4001\"] |
It is recommended to enable TLS for the API and Gateway ports. Configure Nginx as a reverse proxy to protect IPFS from unauthorized access.
Verify and Validate
After configuration, test the service using the following commands:
ipfs ping QmXoypizjW3WknFiJnKLwHCnL72KsS15Dn8g8jW47514K9
ipfs cat /ipfs/QmXoypizjW3WknFiJnKLwHCnL72KsS15Dn8g8jW47514K9
To validate, visit http://your_vps_ip:5001/api/v0/version to check the daemon status. If the response includes version information, the service is running.
Troubleshooting
If the service fails to start, check the logs using ipfs log tail. Common issues include:
- Bootstrap node connection failure: Verify network connectivity and firewall rules.
- Permission issues: Run commands with sudo or check the permissions of the
~/.ipfsdirectory. - Memory overload: Increase RAM or reduce the number of pinned documents.
For optimization, consider using tools like eBPF and Kernel Tracing to monitor system performance.
References
Refer to the official documentation for more details:
Perform Real-World Testing
To verify that the IPFS pinning service is functioning correctly, follow these non-destructive verification steps. This test does not alter configuration, delete data, or disrupt service.
Requirements: The VPS has been configured as per the guide, the IPFS daemon is running, and the internet connection is stable. No external devices, GPUs, or graphical interfaces are required.
Step 1: Check IPFS Daemon Status
ipfs daemon status
Run this command on the VPS. If the output shows Running along with peer ID and repository information, the daemon is active. The result should include details such as API, Gateway, and Repo.
Step 2: Check Pinned Data
ipfs pin ls
Execute this command to view the list of pinned records. After the previous configuration steps, the list should include at least one CID (e.g., QmXoypizjW3WknFiJnKLwHCnL72KsS15Dn8g8jW47514K9). If the list is empty, verify the pinning script or configuration.
Step 3: Test Gateway Access
curl -s http://localhost:80/ipfs/QmXoypizjW3WknFiJnKLwHCnL72KsS15Dn8g8jW47514K9
Run this command to check if the data is accessible via the Gateway (port 80). If the command returns content (typically HTML or JSON), the service is working correctly. If you receive a 404 error or timeout, verify the Addresses.Gateway setting in ~/.ipfs/config and ensure Nginx (if used) is not blocking access.
Step 4: Check Connection to the IPFS Network
ipfs swarm peers
Execute this command to view connected peers. If at least five peers are connected, the VPS has joined the IPFS network. If no peers are connected, check network connectivity, firewall settings, and bootstrap node configuration.
Limitations: This test verifies service status only, not performance or recovery after failure. No GPU or graphical interface is required. The test does not affect existing data on the VPS.
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
