Skip to content

如何把网站发布到 IPFS,并设置域名解析 #4

Description

@fairyly

这是一个快速教程,将教您怎么做

  • 1.在IPFS上托管一个简单的静态网站

  • 2.Add to IPFS
    Next, you need to add the site to IPFS.

$ ipfs add -r site/
  • 2.更改网站内容时,使用IPNS保留一个id(地址)

Publish to IPNS:

现在,您在IPFS上托管了一个简单的静态站点。问题是,每当您更新站点时,哈希值都会更改,并且您共享的任何链接将继续指向旧版本

您需要一种始终共享最新哈希的方法。这就是IPNS的用处。它允许您将对IPFS哈希的引用存储在peerID的名称空间(公共密钥的哈希)下

$ ipfs name publish <your site hash>

This may take a few minutes. We will see how to do this faster using DNSLink below.

You will see something link this after your website has been published using IPNS.

Published to QmdZZgjYoh9sQUonNyefkMyXhEMXFC2rGvhXsJAbAPsF55: /ipfs/QmQToNGFsGMkQe76mRirCvRykJSiRB1JPpRLumyMN7N67T

That will return your peerID(the bold text above) and the hash you are publishing to it. You can confirm by running:

$ ipfs name resolve <peerId>

This will also a few minutes. After this is executed, you will see something like this:

/ipfs/QmQToNGFsGMkQe76mRirCvRykJSiRB1JPpRLumyMN7N67T

or you can view https://gateway.ipfs.io/ipns/<peerID> (notice the directory is ipns not ipfs). This will also a few minutes.
After a few minutes, you will be able to see your website

您必须将网站托管在AWS,GoDaddy等托管服务上,才能完成本教程的其余部分。否则,您可以在此处结束教程

  • 3.使用DNSLink将IPNS ID替换为可读的地址

参考

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions