IPIP-0280: App Conventions for Gateway Detection

Related Issues
ipfs/kubo/issues/8847
git.ffmpeg.org/gitweb/ffmpeg.git/commit/f889837e00d3b2388a24c0a9d075ad62f47da825
curl/curl/pull/8805
History
Commit History
Feedback
GitHub ipfs/specs (inspect source, open issue)

1. Summary

This IPIP creates conventions for how applications can identify an available IPFS gateway, and how IPFS gateway implementations can signal their own endpoint.

This convention has been implemented and in use since 2022 (Kubo 0.15, ffmpeg), with curl support added in curl 8.4.0 (2023).

2. Motivation

Applications wanting to leverage IPFS Gateways are, without a common convention, left to invent their own ways of finding a gateway, including naive approaches such as localhost port scanning.

This IPIP introduces specification that defines how an application wanting to implement IPFS support can find a local or user-preferred gateways.

3. Detailed design

We introduce two ways of hinting user-preferred gateway URL to cover the majority of runtimes and use cases:

See: [gateway-detection] for details.

4. Design rationale

4.1 User benefit

End users can define their preferred gateway once, and benefit from opportunistic support in applications they use.

Application developers save time as they only need to implement support for vendor-agnostic convention to be able to read user preferred gateway.

4.2 Compatibility

4.2.1 Kubo

Kubo (0.15.0 and later) creates a hint file in $IPFS_PATH/gateway (default being $HOME/.ipfs/gateway, see kubo#8847).

The file contains a single line being the local HTTP gateway URL. For example: http://localhost:8080.

Every time ipfs daemon starts with the gateway enabled, it updates the content of $IPFS_PATH/gateway or creates the file if it doesn't exist.

4.2.2 IPFS Chromium

ipfs-chromium uses IPFS_GATEWAY environment variable (ipfs-chromium#29).

It can be a single URL, or a whitespace-separated URLs to be used as the initial gateway pool.

Ref. https://blog.ipfs.tech/2023-05-multigateway-chromium-client/

4.2.3 FFMPEG

FFMPEG's libavformat tries the -gateway option first, then the IPFS_GATEWAY environment variable, then the gateway file under $IPFS_PATH or $HOME/.ipfs/ (ffmpeg.git/commit/f889837). Note that ffmpeg joins $IPFS_PATH and gateway without a path separator, so file detection via IPFS_PATH works only when the value ends with /.

The initial implementation fell back to a hard-coded public gateway; this was removed in ffmpeg.git/commit/412922c for the reason the Security section of [gateway-detection] codifies.

Ref. https://ffmpeg.org/ffmpeg-protocols.html#ipfs, https://blog.ipfs.tech/2022-08-01-ipfs-and-ffmpeg/

4.2.4 Curl

Curl (8.4.0 and later, curl#8805) will try the IPFS_GATEWAY environment variable first, and then look for $IPFS_PATH/gateway or $HOME/.ipfs/gateway, if present. The --ipfs-gateway flag takes precedence over both.

It expects a single URL. Since curl 8.5.0 only the first line of the gateway file is read; 8.4.0 concatenated all lines.

Ref. https://curl.se/docs/ipfs.html

4.2.5 ipfsspec

Python's ipfsspec (0.5.0 and later, ipfsspec#29) enables ipfs:// support in the fsspec ecosystem. It tries the IPFS_GATEWAY environment variable first (a single URL), then reads the first line of a gateway file, checking $IPFS_PATH/gateway, $HOME/.ipfs/gateway, $XDG_CONFIG_HOME/ipfs/gateway, /etc/ipfs/gateway, and OS-specific paths, in that order (get_gateway in async_ipfs.py). When no gateway is found, it raises an error suggesting to run a local node instead of falling back to a public gateway.

4.3 Security

See "Security" section of [gateway-detection].

4.4 Alternatives

4.4.1 Browser Environment Detection

Detection via browser APIs (e.g., localStorage.getItem('IPFS_GATEWAY')) was considered but is explicitly out of scope. Any JavaScript running on a page could overwrite such values and hijack gateway requests. Browser-based detection requires a separate IPIP with proper security review.

4.4.2 Gateway Health Checking

This specification does not mandate health checking of detected gateways. Implementations MAY verify that a gateway is responsive before using it, but the specific approach is left to implementers.

4.4.3 Stale Gateway File Handling

If a daemon crashes without removing the gateway file, it may contain a stale URL. This specification does not mandate specific handling. Implementations MAY implement timeout-based health checks or other recovery mechanisms.

A. References

[gateway-detection]
User-Preferred Gateway Detection. Mark Gaiser; Marcin Rataj. 2026-08-07. URL: https://specs.ipfs.tech/http-gateways/gateway-detection/
[rfc2119]
Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc2119

B. Acknowledgments

We gratefully acknowledge the following individuals for their valuable contributions, ranging from minor suggestions to major insights, which have shaped and improved this specification.

Editors
Mark Gaiser GitHub
Marcin Rataj (Shipyard) GitHub
Special Thanks
Tim Perry GitHub
Dietrich Ayala GitHub
Dave Justice GitHub
dirkf GitHub
Daniel Norman GitHub