Skip to content

Commit 05f55e2

Browse files
Merge pull request #190 from ipfs/feat/native-subdomain-gateways
Update notes about hosting own subdomain gateway
2 parents 2cc9dc1 + cf0a178 commit 05f55e2

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

docs/how-to/address-ipfs-on-web.md

+34-9
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,43 @@ Example:
6363

6464
https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.dweb.link/wiki/
6565
https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.cf-ipfs.com/wiki/Vincent_van_Gogh.html
66+
https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.localhost:8080/wiki/
6667

6768
::: tip
6869

69-
For now, this type of gateway requires additional reverse proxy configuration.
70-
As a reference, Nginx config for subdomain gateway at <code>dweb.link</code> is:
70+
go-ipfs provides native support for subdomain gateways on hostnames defined in [`Gateway.PublicGateways`](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gatewaypublicgateways) configuration map.
7171

72-
```nginx
73-
if ($http_host ~ ^(.+)\.(ipfs|ipns)\.dweb\.link$) {
74-
set $ipfspath /$2/$1;
75-
rewrite "^(.*)$" $ipfspath$1 last;
76-
}
72+
Learn more about daemon configuration for hosting a public gateway:
73+
74+
- [`Gateway.PublicGateways` docs](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gatewaypublicgateways) for defining gateway behavior on specified hostnames
75+
- [`Gateway` recipes](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gatewaypublicgateways) with ready to use one-liners for most common use cases
76+
77+
:::
78+
79+
::: danger
80+
81+
Some browsers and other user agents force lowercase for the authority part of URLs, breaking case-sensitive CIDs before HTTP Gateway has a chance to read them.
82+
83+
To avoid this, use of case-insensitive CIDv1 in Base32 in subdomain context is suggested as the safe default.
84+
85+
:::
86+
87+
::: tip
88+
89+
To convert CID to Base32 use [cid.ipfs.io](https://cid.ipfs.io) or a command line:
90+
91+
```shell
92+
> ipfs cid base32 QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
93+
bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
94+
```
95+
96+
[PeerIDs can be represented as CID with `libp2p-key` multicodec](https://github.com/libp2p/specs/blob/master/RFC/0001-text-peerid-cid.md):
97+
98+
```shell
99+
> ipfs cid format -v 1 -b base32 --codec libp2p-key QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
100+
bafzbeiagwnqiviaae5aet2zivwhhsorg75x2wka2pu55o7grr23ulx5kxm
77101
```
78102

79-
There is ongoing work to <a href="https://github.com/ipfs/go-ipfs/issues/6498" target="_blank">add native subdomain support to the IPFS daemon&nbsp;<i class="fas fa-external-link-square-alt fa-sm"></i></a> which will simplify setup and remove the need for path translation at reverse proxy.
80103
:::
81104

82105
### DNSLink gateway
@@ -113,7 +136,9 @@ ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_
113136
```
114137

115138
::: tip
116-
Support for case-insensitive IPNS roots is a <a href="https://github.com/ipfs/go-ipfs/issues/5287" target="_blank">work in progress&nbsp;<i class="fas fa-external-link-square-alt fa-sm"></i></a>.
139+
140+
Native URI require CID to be case-insensitive. Use of CIDv1 in Base32 is advised.
141+
117142
:::
118143

119144
## Further resources

0 commit comments

Comments
 (0)