From cf0a178a3f91e67a174c60b3bcaafac701de5a9c Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 28 Apr 2020 23:29:34 +0200 Subject: [PATCH] Update notes about hosting own subdomain gateway License: MIT Signed-off-by: Marcin Rataj --- docs/how-to/address-ipfs-on-web.md | 43 +++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/docs/how-to/address-ipfs-on-web.md b/docs/how-to/address-ipfs-on-web.md index 44c0e02dc..e5daca242 100644 --- a/docs/how-to/address-ipfs-on-web.md +++ b/docs/how-to/address-ipfs-on-web.md @@ -63,20 +63,43 @@ Example: https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.dweb.link/wiki/ https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.cf-ipfs.com/wiki/Vincent_van_Gogh.html + https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.localhost:8080/wiki/ ::: tip -For now, this type of gateway requires additional reverse proxy configuration. -As a reference, Nginx config for subdomain gateway at dweb.link is: +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. -```nginx -if ($http_host ~ ^(.+)\.(ipfs|ipns)\.dweb\.link$) { - set $ipfspath /$2/$1; - rewrite "^(.*)$" $ipfspath$1 last; -} +Learn more about daemon configuration for hosting a public gateway: + +- [`Gateway.PublicGateways` docs](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gatewaypublicgateways) for defining gateway behavior on specified hostnames +- [`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 + +::: + +::: danger + +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. + +To avoid this, use of case-insensitive CIDv1 in Base32 in subdomain context is suggested as the safe default. + +::: + +::: tip + +To convert CID to Base32 use [cid.ipfs.io](https://cid.ipfs.io) or a command line: + +```shell +> ipfs cid base32 QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR +bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi +``` + +[PeerIDs can be represented as CID with `libp2p-key` multicodec](https://github.com/libp2p/specs/blob/master/RFC/0001-text-peerid-cid.md): + +```shell +> ipfs cid format -v 1 -b base32 --codec libp2p-key QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN +bafzbeiagwnqiviaae5aet2zivwhhsorg75x2wka2pu55o7grr23ulx5kxm ``` -There is ongoing work to add native subdomain support to the IPFS daemon  which will simplify setup and remove the need for path translation at reverse proxy. ::: ### DNSLink gateway @@ -113,7 +136,9 @@ ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_ ``` ::: tip -Support for case-insensitive IPNS roots is a work in progress . + +Native URI require CID to be case-insensitive. Use of CIDv1 in Base32 is advised. + ::: ## Further resources