无法从我的本地主机连接到 ipfs 集群

can't connect to ipfs cluster from my local host

我在 docker 中有 ipfs 集群 即我已经安装了以下组件:

ipfs init 
ipfs-cluster-service init --consensus raft
ipfs daemon 
ipfs-cluster-service

docker 文件:

  ipfs-cluster-1:
    image: 'ipfs-cluster'
    container_name: ipfs-cluster-1          
    restart: unless-stopped
    ports:
      - "4101:4001"
      - "5101:5001" 
      - "8180:8080" 

来自 docker 的结果(看起来不错)

curl -I http://localhost:8080/ipfs/QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH
HTTP/1.1 301 Moved Permanently
Accept-Ranges: bytes
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Headers: Range
Access-Control-Allow-Headers: User-Agent
Access-Control-Allow-Headers: X-Requested-With
Access-Control-Allow-Methods: GET
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Range
Access-Control-Expose-Headers: X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Output
Cache-Control: public, max-age=29030400, immutable
Content-Length: 5
Content-Type: text/plain; charset=utf-8
Etag: "QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH"
Last-Modified: Thu, 01 Jan 1970 00:00:01 GMT
Location: http://bafybeihuvwfdxuyytwrk3ee64qiurvujhwggfhcbb57sy7r7vz22vxtzza.ipfs.localhost:8080/
X-Ipfs-Path: /ipfs/QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH
Date: Thu, 07 Apr 2022 16:09:13 GMT

我本地的结果(不正常!!!)

curl -I http://localhost:8180/ipfs/QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH
curl: (52) Empty reply from server

你能给点建议吗?

经过一些实验我找到了解决方案

vim  ~/.ipfs/config
change 

    "API": "/ip4/127.0.0.1/tcp/5001",
    "Gateway": "/ip4/127.0.0.1/tcp/8080"
    to 
    "API": "/ip4/0.0.0.0/tcp/5001",
    "Gateway": "/ip4/0.0.0.0/tcp/8080"

PS 在现实生活中你必须替换 0.0.0.0