Setup Your Own IPFS Gateway

Setup Your Own IPFS Gateway

Create VPS on cloud

  1. Create Instance on DO/AWS
  2. Configure a security group with the following options:
Custom TCP: 8080
Custom TCP: 4001–4002
  1. SSH into your EC2 instance

Install “go-ipfs”

  1. Select a Linux binary from
  2. Unzip: tar -xvzf go-ipfs_v0.14.0_linux-amd64.tar.gz
  3. Navigate to the correct directory: cd go-ipfs
  4. Run the install script: sudo bash
  5. Check that IPFS was installed correctly by running: ipfs --version

Initialize the IPFS repository

  1. Create a directory: mkdir /home/ubuntu/data/ipfs
  2. Add the path to your Bash profile:
echo 'export IPFS_PATH=/home/ubuntu/data/ipfs >> ~/.profile'
  1. Reload your bash profile: source ~/.profile
  2. Initialize the IPFS repository: ipfs init --profile server
  3. Open the Gateway on port 8080: ipfs config Addresses.Gateway /ip4/

Set up an IPFS daemon

  1. Create a systemd service: sudo vim /lib/systemd/system/ipfs.service
  2. Add the following contents to the file:
Description=ipfs daemon
ExecStart=/usr/local/bin/ipfs daemon --enable-gc
  1. Save the file
  2. Restart the daemon: sudo systemctl daemon-reload
  3. Enable the service: sudo systemctl enable ipfs.service
  4. Start the service: sudo systemctl start ipfs
  5. Check the status: sudo systemctl status ipfs

Make your IPFS Writable

  1. Edit IPFS configuration: sudo vim /home/ubuntu/data/ipfs/config
  2. Set json key .Gateway.Writable = true
  "Gateway": {
    "APICommands": [],
    "HTTPHeaders": {
      "Access-Control-Allow-Headers": [
      "Access-Control-Allow-Methods": [
      "Access-Control-Allow-Origin": [
    "NoDNSLink": false,
    "NoFetch": false,
    "PathPrefixes": [],
    "PublicGateways": null,
    "RootRedirect": "",
    "Writable": true
  1. Restart ipfs: sudo systemctl restart ipfs

Support Form-Data upload

  1. Nginx proxy
    cat /etc/nginx/conf.d/ipfs_gw.conf
upstream gateway {

upstream api {

server {
    server_name _;
    root /var/www/html;

    access_log /var/log/nginx/access.log;

    listen 80 default_server;
    listen [::]:80 default_server;

    #include conf.d/gateway/denylist.conf;

    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
    add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Range, Content-Range, X-Chunked-Output, X-Stream-Output' always;
    add_header 'Access-Control-Expose-Headers' 'Content-Range, X-Chunked-Output, X-Stream-Output' always;

    client_max_body_size 100M;
    proxy_pass_header Server;
    proxy_read_timeout 1800s;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Ipfs-Gateway-Prefix "";
        proxy_pass http://gateway;

    location /api/v0/ {
        proxy_set_header Host $host;
        proxy_set_header X-Ipfs-Gateway-Prefix "";
        proxy_pass http://api;

1 Like