-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: native redirects config #7392
Comments
This comment has been minimized.
This comment has been minimized.
Thanks so much for this proposal @cwaring! That splat option was particularly useful when we replaced the Filecoin docs site content on Netlify and @andyschwab has confirmed that the forwarding options are much more limited as he tries to move to IPFS on Fleek. Big +1 for this proposal to help developers use familiar patterns when moving their sites to IPFS. |
404 pages will be supported in 0.6.0 (an I'd like to just implement #6214, but there's a performance tradeoff: we'd need to lookup that file for every request to process things like mime types. The nice thing about your proposal is that we only need to perform redirects when content isn't found. |
Would caching help here?
|
maybe later ipfs/kubo#7392
Cloudflare just announced Cloudflare Pages available for free with built-in support for It may now be worth evaluating if redirects could be handled separately from the general-purpose manifest, which is tracked in #6214 By going with |
That sounds like a great idea! |
Some related feedback form https://github.com/Velenir/nextjs-ipfs-example#readme by @Velenir:
If we implement |
Yeah, this looks good! |
Yes I'd love to see this happen and will even easier to port existing static apps to IPFS. Currently Cloudflare only support simple 301/302 redirects but it looks like they will add splats, placeholders etc in the future. We can combine that with an |
Talked about this during the IPFS Operators group. @lidel what do we need to do to move this forward? I think:
There are a bunch of considerations of how a particular operator supports this as part of a publish process to make it work with their system, and we're happy to talk about how we would do it. I think it should be a goal to have this work on arbitrary IPFS gateways for maximum portability. |
Let's do this in go-ipfs, avoid custom behaviors at nginx level: this makes sense only if it is the default behavior on all HTTP gateways, including local ones run by Brave users. The absolute I am happy to review / advise if someone has bandwidth to submit a PR draft. |
Sorry, I've just skim-read this topic, but still have a message to share.
|
Agreed, I think the success condition for IPFS gateways should be output protocol agnosticism--it should work whether it's across HTTP, HTTPS, SCP, FTP, rsync/ssh, etc. without the transport protocol leaking into IPFS itself. After we figure out serving files, I'd be interested in semantic and protocol-agnostic ways to write files to the server. |
Those are valid concerns. Agree on transport agnosticism: there will always be a mode on gateway to fetch raw block or DAG without any post-processing. We will be adding even more explicit way to do this in #8234 The UX/DX improvement discussed here is only relevant when we talk about unixfs with website data that was specifically crafted for consumption via web browsers. A catch-all redirect set up for single-page-application makes little sense when represented on filesystem. Future-proofing websitesI believe our main concern around "website hosting" should be future-proofing. Just to be sure we are on the same page when it comes to the line in sand, some additional context below. Porcelain already provided by go-ipfs gatewayGateways already do various things to make hosting websites more pleasant:
We already have two ways of doing redirects on websites published via ipfs2http gateways:
Are redirects enough?The next here is to decide if support for |
What about introducing gateway plugins and making "Static site hosting" plugin enabled by default which will provide already existing porcelain? |
Something to consider is that Netlify has support for various options (status code, redirect based on header, etc.) |
Either way, we need specs first. Let's consolidate and continue in ipfs/specs#257 |
In case folks come across this, this was resolved in the following issue: #8890 The spec can be found here: https://github.com/ipfs/specs/blob/main/IPIP/0002-gateway-redirects-file.md |
So excited to see this land, thanks everyone for the hard work to make it happen! Extra kudos to @lidel, @justincjohnson ❤️ + @TMoMoreau & @johnnymatthews (for docs) |
The documentation for this can be found here: https://docs.ipfs.tech/how-to/websites-on-ipfs/redirects-and-custom-404s/#evaluation This issue shows up highly when searching for redirects on IPFS, so wanted to make sure folks can find the actual docs on it if they end up here. |
Native redirects for Web Apps on IPFS
Problem
When hosting a website or application on IPFS served via a gateway you will often need to manage redirects to ensure links are not broken for previously referenced urls, these can appear in search indexes or external sites. If a path is changed and you are not manually proxying results from IPFS via a web-server with configured redirects then a user is presented an unhelpful 404 error, such as:
This is currently true for results redirected to a local node via IPFS Companion or for IPFS hosting services such as Fleek.
Proposal
We allow a plain text root
_redirects
config that could be checked to transparently redirect to the new resource, with optional response codes for correct routing.How could this work?
Each deploy could include a
_redirects
config at the root of the CID tree which could be checked bygo-ipfs
in attempt to locate the new resource or follow a pattern to gracefully direct users to the new location.A few examples:
Splats
Placeholders
Client-side apps with history pushstate (React, Vue, Angular, etc)
When developing a single page app with client-side routing you often wish the delegate all routing to the application using a rule like this.
Custom 404 pages
If a resource can not be resolved then fallback to matching a root /404.html or a custom option by matching a path
These examples are based on syntax from the Netlify _redirect configuration file, which I believe is a great pattern to follow as it is simple and would allow easy migration for existing apps hosted on Netlify.
Related Issues
#6214
ipfs-inactive/docs#405
If there is other existing work, issues or solutions that I have missed please add them to the discussion below and I'll include them in this proposal.
The text was updated successfully, but these errors were encountered: