ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.17k stars 3.01k forks source link

For IPNS to redirect to a custom 404 not found landing page #5916

Open basile-henry opened 8 years ago

basile-henry commented 8 years ago

When doing IPNS lookups through DNS using the TXT record trick (dnslink=/ipns/), it would be nice to be able to setup a custom 404 not found landing page.

Right now if a wrong URL is given the following happens: https://ipfs.io/asdf returns Path Resolve error: no link named "asdf" under QmXkYb9qNw3vHHf5WmK9ckNSW6h1j5j7wAwGL6zG5TtZDP

I've tested on my own IPFS node and it looks like the daemon throws a 505 error code when it can't resolve the path. I don't care so much about which error code it is but I think it would be neat if we could setup a hash for some other content to be served on such error. This might go against the content addressable property of IPFS though. But maybe there's enough flexibility within IPNS to deal with such a "feature".

The main reason I'm bringing this up is that I seem to understand that for IPFS to replace HTTP or at least to cohabit with it, it should behave in the same way from the user's point of view. Plus a proper landing page on an error is probably more meaningful to the user than a Path Resolve error message.

jphastings commented 7 years ago

At the moment index.html has special meaning for the IPFS -> HTTP gateway, could we give 404.html special meaning too? ie. when presenting any IPFS directory in a browser the /404.html file would be rendered instead of the error @basile-henry noted above.

This would mean that these 404 pages would display on public gateways as well as ones set up to proxy a specific hash.

magik6k commented 5 years ago

Related PR: https://github.com/ipfs/go-ipfs/pull/4233

straiforos commented 4 years ago

I think this is interesting but I do believe it is up to the http server to make this redirect and possibly should be configured in the http gateway. I am not sure if it makes sense for IPNS to be responsible for this logic as this is kind of a p2p DNS service and to link content access with a domain service/api would be a bad abstraction. I am very interested in making a scalable architecture that hosts a plethora of services built on the p2p data sharing peers that IPFS offers both on the public and private networks.

So I think it has merit but I believe the logic belongs at the gateway layer which could be an API gateway or typical web api server model that sends a 404 page and the appropriate headers. Currently working on integrating caddy server v2 into ipfs gateway for secure only access and route users to a insecure webui for insecure connections like a 404 to educate users of the dangers of http access. (slight tangent)

itsKV commented 2 years ago

At the moment index.html has special meaning for the IPFS -> HTTP gateway, could we give 404.html special meaning too? ie. when presenting any IPFS directory in a browser the /404.html file would be rendered instead of the error @basile-henry noted above.

This would mean that these 404 pages would display on public gateways as well as ones set up to proxy a specific hash.

Where is the root folder for ipfs public gateway? i.e where to place index.html file to serve that page if user tries to access https://ipfs.example.com/ root domain? I just want to show a welcome message to visitor if he hit a root url. Currently I am getting 404 error.