1
- # IPIP-386: Subdomain Gateway interop with _ redirects
2
-
3
- <!-- IPIP number should match its pull request number. After you open a PR,
4
- please update title and include anqabbreviated title in the filename too:
5
- `0000-draft-title-abbrev.md`. -->
6
-
7
- - Start Date: 2023-03-18
8
- - Related Issues:
9
- - IPIP-2 _ redirects file
1
+ ---
2
+ title : " IPIP-0386: Subdomain Gateway Interop with _redirects"
3
+ date : 2023-03-18
4
+ ipip : proposal
5
+ editors :
6
+ - name : suicide
7
+ github : suicide
8
+ relatedIssues :
9
+ - https://github.com/ipfs/boxo/pull/326
10
+ - https://github.com/ipfs/boxo/pull/412
11
+ order : 386
12
+ tags : ['ipips']
13
+ ---
10
14
11
15
## Summary
12
16
13
- <!-- One paragraph explanation of the IPIP.-->
14
- This IPIP suggests a tweak in the Path and Subdomain Gateway interop to
15
- leverage the ` _redirects ` file.
17
+ This IPIP clarifies the Path and Subdomain Gateway interop to
18
+ ensure features like ` _redirects ` file work correctly.
16
19
17
20
## Motivation
18
21
@@ -22,7 +25,7 @@ On traditional hosting, deep links are redirected or rewritten to a single
22
25
entry point, e.g. ` /index.html ` , and the router on the client side evaluates
23
26
the path segments to render the correct content.
24
27
25
- The ` _redirects ` file, defined in [ ` REDIRECTS_FILE.md ` ] ( ../REDIRECTS_FILE.md ) ,
28
+ The ` _redirects ` file, defined in : cite [ web-redirects-file ] ,
26
29
supports such applications when a Subdomain Gateway is used directly. However,
27
30
the current resolution of native URLs uses a Path Gateway link scheme and
28
31
subsequently fails to resolve the URL correctly.
@@ -33,7 +36,7 @@ For example:
33
36
- ` http://{gateway}/ipns/example.org/some/path `
34
37
- this request fails with 404 as the resource ` /some/path ` does not exist.
35
38
36
- NOTE: The ` kubo ` gateway returns a 404 including a new ` Location ` header
39
+ NOTE: The ` kubo ` (<0.20) gateway returns a 404 including a new ` Location ` header
37
40
already pointing to the correct subdomain URL. But browsers do not follow the
38
41
header as the status is 404, and the response contains a ` text/plain ` body
39
42
string.
@@ -73,7 +76,7 @@ not found in the directory identified by the CID or DNSLink name.
73
76
74
77
## Test fixtures
75
78
76
- The example from the [ REDIRECTS_FILE.md ] ( ../REDIRECTS_FILE.md ) can be re-used,
79
+ The example from the : cite [ web-redirects-file ] can be re-used,
77
80
` QmYBhLYDwVFvxos9h8CGU2ibaY66QNgv8hpfewxaQrPiZj ` .
78
81
79
82
```
@@ -115,14 +118,14 @@ $ curl -v http://{gateway}/ipfs/QmYBhLYDwVFvxos9h8CGU2ibaY66QNgv8hpfewxaQrPiZj/r
115
118
...
116
119
```
117
120
118
- Subsequent requests should comply with IPIP-2 .
121
+ Subsequent requests should comply with : cite [ ipip-0002 ] .
119
122
120
123
## Design rationale
121
124
122
- Gateways like ` kubo ` already support the suggested redirect but block the
123
- redirect chain by returning a 404 when a resource is not found on the Path
124
- Gateway. By removing the 404, users get another chance to find the resources
125
- they are looking for.
125
+ Gateways like ` kubo ` (before v0.20) already support the ` _redirect ` and
126
+ subdomain redirect, but block the redirect chain by returning a 404 when a
127
+ resource is not found on the Path Gateway. By moving the 404 to occur at the
128
+ subdomain, users get another chance to find the resources they are looking for.
126
129
127
130
### User benefit
128
131
@@ -134,15 +137,17 @@ compatibility.
134
137
135
138
### Compatibility
136
139
137
- This proposal improves the reach of ` _redirects ` files.
140
+ This proposal fixes a bug in handling of ` _redirects ` files.
138
141
139
- The current behavior is defined in [ PATH_GATEWAY.md ] ( ../PATH_GATEWAY.md ) . The
142
+ The current behavior is defined in : cite [ path-gateway ] . The
140
143
404 return code indicates that a resource does not exist. Changing this to a
141
144
301 redirect that is subsequently answered with a 404 from the subdomain URL
142
- might break clients.
145
+ is a breaking change, but the old behavior should be considered as a bug.
146
+
147
+ Requesting an existing resource on the Path Gateway URL in ` kubo ` already
148
+ returns a 301 redirect: client expectation is for the behavior to be the same
149
+ for invalid paths.
143
150
144
- However, requesting an existing resource on the Path Gateway URL in ` kubo `
145
- already returns a 301 redirect while also providing the content in the body.
146
151
147
152
### Security
148
153
@@ -154,7 +159,8 @@ security due to host separation.
154
159
155
160
Gateways could continue to return a 404 response for the non-existing resource,
156
161
but also include an HTML body containing a redirect link. This would help users
157
- to find the requested site.
162
+ to find the requested site, but comes with worse UX than the fix proposed in
163
+ this IPIP.
158
164
159
165
### Copyright
160
166
0 commit comments