| title | description | date | maturity | editors | xref | tags | order | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DNSLink Gateway Specification |
Defines how to utilize the HTTP Host header to serve a content path from a DNSLink record as a website under a particular DNS name.
|
2022-11-09 |
reliable |
|
|
|
4 |
DNSLink Gateway is an extension of :cite[path-gateway] that enables hosting a specific content path under a specific DNS name.
This document describes the delta between :cite[path-gateway] and this gateway type.
In short:
- HTTP request includes a valid DNSLink name in
Hostheader - gateway decides if DNSlink name is allowed
- gateway resolves DNSLink to an immutable content root identified by a CID
- HTTP response includes the data for the CID
Downloads data at specified path under the content path for DNSLink name provided in Host header.
path– optional path to a file or a directory under the content root sent inHostHTTP header- Example: if
Host: example.comthen the content path to resolve is/ipns/example.com/{path}
- Example: if
Same as GET, but does not return any payload.
Below MUST be implemented in addition to "HTTP Request" of :cite[path-gateway].
Defines the DNSLink name
to RECURSIVELY resolve into an immutable /ipfs/{cid}/ prefix that should
be prepended to the path before the final IPFS content path resolution
is performed.
Implementations MUST ensure DNSLink resolution is safe and correct:
- each DNSLink may include an additional path segment, which MUST be preserved
- each DNSLink may point at other DNSLink, which means there MUST be a hard recursion limit (e.g. 32) and HTTP 400 Bad Request error MUST be returned when the limit is reached.
:::note
Example: resolving an advanced DNSLink chain
To illustrate, given DNSLink records:
_dnslink.a.example.comTXT record:dnslink=/ipns/b.example.net/path-b_dnslink.b.example.netTXT record:dnslink=/ipfs/bafy…qy3k/path-c
HTTP client sends GET /path-a request with Host: a.example.com header
which recursively resolves all DNSLinks and produces the final immutable
content path:
Hostheader +/path-a→/ipns/a.example.net/path-a- Resolving DNSlink at
a.example.netreplaces/ipns/a.example.netwith/ipns/b.example.net/path-b - Resolving DNSlink at
b.example.netreplaces/ipns/b.example.netwith/ipfs/bafy…qy3k/path-c - The immutable content path is
/ipfs/bafy…qy3k/path-c/path-b/path-a
:::
Same as "HTTP Response" of :cite[path-gateway].
- It is a good idea to publish DNSAddr TXT records with known content providers for the data behind a DNSLink. IPFS clients will be able to detect DNSAddr and preconnect to known content providers, removing the need for expensive DHT lookup.
DNSLink Gateway implementations SHOULD include _redirects file support
defined in :cite[web-redirects-file].