Skip to content

Hostnames for localhost HTTP gateway #109

@lidel

Description

@lidel

Motivation

  • At some point in the future we may have native protocol handler (libdweb+[PoC] libdweb experiment: protocol handler API ipfs-companion#533 or similar), but for now the URL in address bar remains fugly less than pretty
  • The latest Companion extension supports DNSLink-based redirects from URLs like http://docs.ipfs.io to a local go-ipfs gateway at http://127.0.0.1:8080/ipns/docs.ipfs.io/
  • Our public gateways start to support cidv1b32 in Subdomains (CID as a Subdomain #89), which restores Origin-based isolation between websites. This also means we don't want to redirect such URLs to local gateway as it would remove this isolation.

Requirements

I wonder if there is a way of generating vanity hostnames pointing at localhost that:

  • does not require lookups to an external DNS server
  • keeps HTML content in secure context
  • works out-of-the box on windows, mac and linux
    • alternatively we can add heuristics to pick method based on user's platform
  • lets us introduce subdomain-driven Origin isolation for locally running gateway
  • (nice to have, but we can work around this for embedds) does not trigger mixed-content warnings when IPFS resource from localhost is embedded on HTTPS website
    • it is what happens when /ipfs/{cid} is redirected from public gateway running on https to a custom one running on http
    • this may be the blocker: AFAIK only 127.0.0.1 and ::1 are whitelisted by browser vendors (eg. firefox #903966) but localhost is not (that is why Companion uses raw IP)
    • as of 2019-10 localhost is a secure context in both Firefox and Chrome. Firefox does not support subdomains (foo.bar.localhost is not a secure context)

If anyone has unconventional ideas, feel free to comment.

Candidates

*.localhost

Current status

🔒 – window.isSecureContext === true
💢 – window.isSecureContext === false

Status Firefox Chrome
127.0.0.1 🔒 🔒
localhost 🔒 🔒
foo.bar.localhost 💢 🔒

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions