Description
Base32-encoded CIDv1 can be used in DNS subdomains. It requires additional setup server-side, but enables people to get a valid origin-based security perimeter for free.
This is a meta issue for tracking related notes and developments.
Zone Naming Convention
To make it easier for everyone, support for CID in subdomains comes with explicit zone naming convention:
https://<cidv1b32>.ipfs.<example.tld>
the CID will always be in a zone named
ipfs
(oripns
), e.g.
http://bafkreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy.ipfs.dweb.link
– ipfs/ipfs-companion#526 (comment)
Nginx config
For now, this needs to be handled by reverse proxy.
An example of subdomain config for gateway at dweb.link
:
if ($http_host ~ ^(.+)\.(ipfs|ipns)\.dweb\.link$) {
set $ipfspath /$2/$1;
rewrite "^(.*)$" $ipfspath$1 last;
}
Native config (go-ipfs >0.5.0)
Native support for CID in Host
header ship with go-ipfs 0.5.0 and later.
It removes the need for Nginx config mentioned above, and can be enabled with this one-liner (dweb.link
is the domain that should support $cid.ipfs.dweb.link
):
$ ipfs config --json Gateway.PublicGateways '{
"dweb.link": {
"UseSubdomains": true,
"Paths": ["/ipfs", "/ipns"]
}
}'
Length Limits
Subdomain needs to comply with length limits from RFC 1034:
Each node has a label, which is zero to 63 octets in length. #
To simplify implementations, the total number of octets that represent a
domain name (i.e., the sum of all label octets and label lengths) is
limited to 255. #
CIDv1(sha-256) in Base32 fits, but hashes with longer outputs can't be used as a single label.
Update: Potential solutions are discussed in:
ipfs/kubo#7318