Skip to content

Commit bcd9b13

Browse files
authored
Merge pull request #500 from ipfs/gateway-psl-note
subdomain gateway: clarify PSL and eTLD best practices
2 parents 9294ac7 + 1fdd54f commit bcd9b13

File tree

1 file changed

+39
-22
lines changed

1 file changed

+39
-22
lines changed

src/http-gateways/subdomain-gateway.md

+39-22
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ description: >
66
ensures compatibility with native ipfs:// and ipns:// URIs, and aligns with
77
the existing Same-origin security model in web browsers, including
88
relative URL pathing and permission scopes of Web APIs.
9-
date: 2023-01-28
9+
date: 2025-04-03
1010
maturity: reliable
1111
editors:
1212
- name: Marcin Rataj
1313
github: lidel
14-
url: https://lidel.org/
1514
affiliation:
16-
name: Protocol Labs
17-
url: https://protocol.ai/
15+
name: Shipyard
16+
url: https://ipshipyard.com
1817
- name: Adrian Lanzafame
1918
github: lanzafame
2019
affiliation:
@@ -204,7 +203,7 @@ See also: [Migrate from Path to Subdomain Gateway](#migrating-from-path-to-subdo
204203

205204
See: [URI router](#uri-router)
206205

207-
# Appendix: notes for implementers
206+
# Appendix: Notes for implementers
208207

209208
## Migrating from Path to Subdomain Gateway
210209

@@ -244,22 +243,38 @@ should return HTTP 400 Bad Request for CIDs longer than 63.
244243

245244
## Security considerations
246245

247-
- Wildcard TLS certificates should be set for `*.ipfs.example.net` and
248-
`*.ipns.example.net` if a subdomain gateway is to be exposed on the public
249-
internet.
250-
- If TLS termination takes place outside of gateway implementation, then
251-
setting [`X-Forwarded-Proto`](#x-forwarded-proto-request-header) at a
252-
reverse HTTP proxy can be used for preserving `https` protocol.
253-
254-
- Subdomain gateways provide unique origin per content root, however the
255-
origins still share the parent domain name used by the gateway. To fully
256-
isolate websites from each other:
257-
- The gateway operator should add a wildcard entry
258-
to the [Public Suffix List](https://publicsuffix.org/) (PSL).
259-
- Example: `dweb.link` gateway [is listed on PSL](https://publicsuffix.org/list/public_suffix_list.dat) as `*.dweb.link`
260-
- Web browsers with IPFS support should detect subdomain gateway (URL
261-
pattern `https://{content-root-id}.ip[f|n]s.example.net`) and dynamically
262-
append it to internal PSL.
246+
### Wildcard TLS certificates
247+
248+
Wildcard TLS certificates SHOULD be set for `*.ipfs.example.net`
249+
and `*.ipns.example.net` if a subdomain gateway is to be exposed on the public
250+
internet.
251+
252+
If TLS termination takes place outside of gateway implementation, then setting
253+
[`X-Forwarded-Proto`](#x-forwarded-proto-request-header) at a reverse HTTP
254+
proxy is RECOMMENDED for preserving `https` protocol.
255+
256+
### Public Suffix List and eTLD enforcement
257+
258+
Subdomain gateways assign each content root a unique origin, yet these origins
259+
share the gateway’s parent domain. Without proper isolation, all subdomains
260+
under the same effective Top-Level Domain (eTLD) face risks: a single
261+
problematic CID could trigger widespread blocking of the entire gateway by
262+
software like Safe Browsing
263+
([incident example](https://web.archive.org/web/20230930054837/https://blog.nft.storage/posts/2022-04-29-gateways-and-gatekeepers)).
264+
265+
To mitigate this and align with the web’s Same-origin security model, operators
266+
SHOULD register a wildcard entry like `*.example.net`
267+
with the [Public Suffix List (PSL)](https://publicsuffix.org/).
268+
269+
This will make `ipfs.example.net` and `ipns.example.net` eTLDs, treating each
270+
identifier (e.g., `cid.ipfs.example.net`) as a distinct top-level Origin.
271+
The [public good gateway](https://docs.ipfs.tech/concepts/public-utilities/#public-ipfs-gateways),
272+
listed as `*.dweb.link` and `*.inbrowser.link` on the PSL, exemplifies this approach.
273+
274+
Browsers supporting IPFS natively SHOULD detect URI patterns such as
275+
`https://{content-root-id}.ip[f|n]s.example.net` and dynamically update their
276+
internal PSL, bolstering security and compatibility without relying solely on
277+
operator action.
263278

264279
## URI router
265280

@@ -272,7 +287,7 @@ addresses on a gateway.
272287
The `/ipfs/?uri=%s` endpoint MUST be compatible with :ref[registerProtocolHandler(scheme, url)],
273288
present in web browsers. The value passed in `%s` should be :ref[UTF-8 percent-encode].
274289

275-
**Example**
290+
:::example
276291

277292
Given registration:
278293

@@ -289,6 +304,8 @@ which in turn should redirect to
289304

290305
From there, regular subdomain gateway logic applies.
291306

307+
:::
308+
292309
## Redirects, single-page applications, and custom 404s
293310

294311
Subdomain Gateway implementations SHOULD include `_redirects` file

0 commit comments

Comments
 (0)