How to setup IPFS public gateway?

1.1k Views Asked by At

Hello all community members and developers,

I am trying to set up the public IPFS gateway on my AWS server.

I have installed the Golang and IPFS successfully on the server. and as I try running the IPFS node (IPFS Daemon), my IPFS node starts successfully and everything looks fine.

as you can see the output below.

$ sudo systemctl status ipfs 
● ipfs.service - IPFS Daemon
     Loaded: loaded (/lib/systemd/system/ipfs.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-06-30 07:59:32 UTC; 1h 19min ago
   Main PID: 17324 (ipfs)
      Tasks: 7 (limit: 1145)
     Memory: 229.1M
     CGroup: /system.slice/ipfs.service
             └─17324 /usr/local/bin/ipfs daemon

Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Swarm listening on /p2p-circuit
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Swarm announcing /ip4/127.0.0.1/tcp/4001
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Swarm announcing /ip4/127.0.0.1/udp/4001/quic
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Swarm announcing /ip4/3.34.152.151/udp/4001/quic
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Swarm announcing /ip6/::1/tcp/4001
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Swarm announcing /ip6/::1/udp/4001/quic
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: API server listening on /ip4/0.0.0.0/tcp/5001
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: WebUI: http://0.0.0.0:5001/webui
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Gateway (writable) server listening on /ip4/0.0.0.0/tcp/8080
Jun 30 07:59:33 ip-172-31-34-147 ipfs[17324]: Daemon is ready

everything looks fine up to here, but as I try to access my gateway using which is running on port 8080 it won't respond.

My AWS server public IP address is 3.34.152.151 and I am trying to access my IPFS gateway using http://http://3.34.152.151:8080/ipfs/, but it is not working.

Also I have allowed the ports not to be blocked by firewall,

sudo firewall-cmd --zone=public --add-port=4001/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent

but still I am not able to access my gateway at http://http://3.34.152.151:8080/ipfs/

Here is my IPFS config file.

{
  "API": {
    "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": []
  },
  "Addresses": {
    "API": "/ip4/0.0.0.0/tcp/5001",
    "Announce": [],
    "AppendAnnounce": [],
    "Gateway": "/ip4/0.0.0.0/tcp/8080",
    "NoAnnounce": [
      "/ip4/10.0.0.0/ipcidr/8",
      "/ip4/100.64.0.0/ipcidr/10",
      "/ip4/169.254.0.0/ipcidr/16",
      "/ip4/172.16.0.0/ipcidr/12",
      "/ip4/192.0.0.0/ipcidr/24",
      "/ip4/192.0.2.0/ipcidr/24",
      "/ip4/192.168.0.0/ipcidr/16",
      "/ip4/198.18.0.0/ipcidr/15",
      "/ip4/198.51.100.0/ipcidr/24",
      "/ip4/203.0.113.0/ipcidr/24",
      "/ip4/240.0.0.0/ipcidr/4",
      "/ip6/100::/ipcidr/64",
      "/ip6/2001:2::/ipcidr/48",
      "/ip6/2001:db8::/ipcidr/32",
      "/ip6/fc00::/ipcidr/7",
      "/ip6/fe80::/ipcidr/10"
    ],
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001",
      "/ip4/0.0.0.0/udp/4001/quic",
      "/ip6/::/udp/4001/quic"
    ]
  },
  "AutoNAT": {},
  "Bootstrap": [
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
    "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
    "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
  ],
  "DNS": {
    "Resolvers": {}
  },
  "Datastore": {
    "BloomFilterSize": 0,
    "GCPeriod": "1h",
    "HashOnRead": false,
    "Spec": {
      "mounts": [
        {
          "child": {
            "path": "blocks",
            "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
            "sync": true,
            "type": "flatfs"
          },
          "mountpoint": "/blocks",
          "prefix": "flatfs.datastore",
          "type": "measure"
        },
        {
          "child": {
            "compression": "none",
            "path": "datastore",
            "type": "levelds"
          },
          "mountpoint": "/",
          "prefix": "leveldb.datastore",
          "type": "measure"
        }
      ],
      "type": "mount"
    },
    "StorageGCWatermark": 90,
    "StorageMax": "10GB"
  },
  "Discovery": {
    "MDNS": {
      "Enabled": false,
      "Interval": 10
    }
  },
  "Experimental": {
    "AcceleratedDHTClient": false,
    "FilestoreEnabled": false,
    "GraphsyncEnabled": false,
    "Libp2pStreamMounting": false,
    "P2pHttpProxy": false,
    "StrategicProviding": false,
    "UrlstoreEnabled": false
  },
  "Gateway": {

    "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": []
  },
  "Identity": {
    "PeerID": "12D3KooWPAnHKFnH4SeSx2LdkgRdVQ54RuHdfnUZMWM16YTgnHBw",
    "PrivKey": "CAESQEpsG26Nkh51+jLSNtpknqmnuOSMhAKDYI+uDP7pWgslxmLPq7Fh1EUSBKDSMfY3Uq8GMXZmspW7W/OYZe3277I="
  },
  "Internal": {},
  "Ipns": {
    "RecordLifetime": "",
    "RepublishPeriod": "",
    "ResolveCacheSize": 128
  },
  "Migration": {
    "DownloadSources": [],
    "Keep": ""
  },
  "Mounts": {
    "FuseAllowOther": false,
    "IPFS": "/ipfs",
    "IPNS": "/ipns"
  },
  "Peering": {
    "Peers": null
  },
  "Pinning": {
    "RemoteServices": {}
  },
  "Plugins": {
    "Plugins": null
  },
  "Provider": {
    "Strategy": ""
  },
  "Pubsub": {
    "DisableSigning": false,
    "Router": ""
  },
  "Reprovider": {
    "Interval": "12h",
    "Strategy": "all"
  },
  "Routing": {
    "Type": "dht"
  },
  "Swarm": {
    "AddrFilters": [
      "/ip4/10.0.0.0/ipcidr/8",
      "/ip4/100.64.0.0/ipcidr/10",
      "/ip4/169.254.0.0/ipcidr/16",
      "/ip4/172.16.0.0/ipcidr/12",
      "/ip4/192.0.0.0/ipcidr/24",
      "/ip4/192.0.2.0/ipcidr/24",
      "/ip4/192.168.0.0/ipcidr/16",
      "/ip4/198.18.0.0/ipcidr/15",
      "/ip4/198.51.100.0/ipcidr/24",
      "/ip4/203.0.113.0/ipcidr/24",
      "/ip4/240.0.0.0/ipcidr/4",
      "/ip6/100::/ipcidr/64",
      "/ip6/2001:2::/ipcidr/48",
      "/ip6/2001:db8::/ipcidr/32",
      "/ip6/fc00::/ipcidr/7",
      "/ip6/fe80::/ipcidr/10"
    ],
    "ConnMgr": {
      "GracePeriod": "20s",
      "HighWater": 900,
      "LowWater": 600,
      "Type": "basic"
    },
    "DisableBandwidthMetrics": false,
    "DisableNatPortMap": true,
    "RelayClient": {},
    "RelayService": {},
    "ResourceMgr": {},
    "Transports": {
      "Multiplexers": {},
      "Network": {},
      "Security": {}
    }
  }
}

Also inside the config I have tried changing the gateway from "Gateway": "/ip4/0.0.0.0/tcp/8080" or "Gateway": "/ip4/127.0.0.1/tcp/8080" to my server IP address i.e "Gateway": "/ip4/3.34.152.151/tcp/8080" but it also won't work for me.

I have followed dozens of articles and nothing seems to work for me.

what I am looking to do?

I want to make this gateway public, public means anyone in this world can access this gateway using http://<MY_AWS_SERVER_IP>:8080/ipfs/<CID>

as of now, I want this, I am also aware that exposing the API endpoints of IPFS does not come under the best practices. but just for some testing, I am exposing my API endpoints too but it's temporary.

As of now, I am looking for your help in resolving this issue, why I am not able to access the IPFS gateway running on my AWS server at http://3.34.152.151:8080/ipfs using my local computer.

Thanks

0

There are 0 best solutions below