Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit 51ec9ba

Browse files
committed
Document use of CNAME for hosting ipfs sites.
1 parent 60a9528 commit 51ec9ba

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

examples/websites/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ added QmYeAiiK1UfB8MGLRefok1N7vBTyX8hGPuMXZ4Xq1DPyt7 mysite/
1818
```
1919

2020
The very last hash next to the folder name is the one you want, lets call it
21-
`$SITE_HASH` for now.
21+
`$SITE_HASH` for now.
2222

2323
Now, you can test it out locally by opening `http://localhost:8080/ipfs/$SITE_HASH`
2424
in your web browser! Next, to view it coming from another ipfs node, you can try
@@ -48,10 +48,20 @@ And also try the same link on the public gateway. Once you're convinced that wor
4848
lets again hide the hash. Change your DNS TXT record to `dnslink=/ipns/<your peer id>`,
4949
wait for that record to propogate, and then try accessing `http://localhost:8080/ipns/your.domain`.
5050

51-
At this point, you have a website on ipfs/ipns, and you may be wondering how you could expose it at `http://your.domain`, so that the Internet users of today may access it too without them having to know about any of this. It's actually surpisingly simple to do, all you need for this is your previously created TXT record and to point the A record of `your.domain` to the ip address of an ipfs daemon that listens on port 80 for HTTP requests (such as `gateway.ipfs.io`). The users' browsers will send `your.domain` in the Host header of the requests, and you have your dnslink TXT records, so the ipfs gateway will recognize `your.domain` as an IPNS name, and so it will serve from under `/ipns/your.domain/` instead of `/`.
51+
At this point, you have a website on ipfs/ipns, and you may be wondering how you could expose it at `http://your.domain`, so that the Internet users of today may access it too without them having to know about any of this. It's actually surpisingly simple to do, all you need for this is your previously created TXT record and to point the A record of `your.domain` to the IP address of an ipfs daemon that listens on port 80 for HTTP requests (such as `gateway.ipfs.io`). The users' browsers will send `your.domain` in the Host header of the requests, and you have your dnslink TXT records, so the ipfs gateway will recognize `your.domain` as an IPNS name, and so it will serve from under `/ipns/your.domain/` instead of `/`.
5252

5353
So, if you point `your.domain`'s A record to the IP of `gateway.ipfs.io`, and then wait for the DNS to propogate, then anyone should be able to access your ipfs-hosted site without any extra configuration simply at `http://your.domain`.
5454

55+
Alternately, it is possible to use CNAME records to point at the DNS records of
56+
the gateway. This way, IP addresses of the gateway are automtically
57+
updated. Note however that CNAME records to not allow for other records, such as
58+
a TXT to refer to the ipfs/ipns record. Because of this, ipfs allows to create
59+
a DNS TXT record for `_dnslink.your.domain` with `dnslink=/ipns/<your peer id>`.
60+
61+
So by creating a CNAME for `your.domain` to `gateway.ipfs.io` and adding a
62+
`_dnslink.your.domain` record with `dnslink=/ipns/<your peer id>` you can host
63+
your website without explicitly referring to IP addresses of the ipfs gateway.
64+
5565
Happy Hacking!
5666

5767
By

0 commit comments

Comments
 (0)