1. 用 Docker Compose 部署 IPFS-Kubo
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
version: '3.8' services: ipfs: container_name: ipfs-node image: "ipfs/kubo:latest" restart: unless-stopped volumes: - ipfs_path:/data/ipfs - ipfs_fuse:/ipfs - ipns_fuse:/ipns environment: - IPFS_PATH=/data/ipfs ports: # Swarm listens on all interfaces, so is remotely reachable. - 4001:4001/tcp - 4001:4001/udp # The following ports only listen on the loopback interface, so are not remotely reachable by default. # If you want to override these or add more ports, see https://docs.docker.com/compose/extends/ . # API port, which includes admin operations. - 5001:5001 # HTTP Gateway - 8080:8080 volumes: ipfs_path: ipfs_fuse: ipns_fuse: |
2. 允許從外部訪問 IPFS Web UI
備註:將第一行 Access-Control-Allow-Origin 後面啲 URL 改成 Server 嘅內網 IP。
|
1 2 |
docker exec ipfs-node ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://192.168.82.29:5001","http://localhost:3000", "http://127.0.0.1:5001", "https://webui.ipfs.io"]' docker exec ipfs-node ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]' |