LNS web Draft · 27 November 2026

8. Gateways

A gateway is an HTTP view of LNS sites for ordinary web browsers. It resolves an LNS name, checks every byte against the hashes the record pins, and serves the result with no page code and a banner that says it is a user site.

Describes the gateway at <name>.lnsweb.online, round 3 (serve.mjs with sanitizer revision s3, reserved.mjs, gateway-config.mjs), live. Numbers are this gateway's defaults. Only the requirements marked in boxes apply to every gateway.

8.1 What a gateway is

A web browser cannot resolve lns:// addresses or check a Logos Storage hash. A gateway does both on the browser's behalf and answers over HTTPS. Anyone can run one. This page specifies what every gateway must do, then describes the one at lnsweb.online.

A gateway visitor gets less than a Names Browser user. The visitor cannot check the gateway's work: they trust the gateway operator, its RPC and the TLS front end not to change what is served (section 8.12). For full checks, open the same address in the Names Browser.

A gateway MUST verify every root, folder list and file against the SHA-256 pinned above it (sections 5 and 6) before it sends any byte of it, and MUST refuse an entry that pins no SHA-256.

A gateway MUST NOT run a site's scripts or let them run in the visitor's browser.

A gateway MUST show, on every HTML page it serves, that the page is a user site and which LNS name it came from, in a way the page cannot hide.

This gateway: serve.mjs fetchVerifiedBlob and downloadVerified (whole blob hashed before the response starts), resolveLinksTree with requireSha256: true; scripts removed in sanitize.mjs and blocked by the CSP script-src 'none'; banner from buildHeaderBar.

8.2 Host to name

This gateway serves each site on its own hostname, <name>.<domain>, where the domain is the setting GATEWAY_DOMAIN (now lnsweb.online). So lns://alice/docs/intro.html is served at:

https://alice.lnsweb.online/docs/intro.html

It reads the name from the Host header like this:

  1. Drop a port, if any (1 to 65535). Lower-case the rest. Refuse a host with control characters, spaces or any of / \ ? # @ [ ], or longer than 260 characters.
  2. Refuse the apex (lnsweb.online itself) and any host outside the domain.
  3. What is left before .<domain> must be exactly one label. a.b.lnsweb.online is refused.
  4. Refuse a label that starts with xn-- (Punycode), so a browser never shows it as a look-alike Unicode name. An LNS name such as xn--abc is valid, but this gateway does not serve it.
  5. The label must be a valid LNS name: 1 to 32 characters of a-z, 0-9 and -, not starting or ending with - (section 4.1).
  6. Refuse a reserved label (below).

Every refusal is the same short 404, "No LNS site is served at this host."

Reserved labels. This gateway reserves 101 labels, so that no site can appear at a hostname that looks like part of the service. They fall in three groups:

The last one is lez, the chain RPC host. Other words the main site uses, such as wallet or explorer, are not reserved here: they are locked LNS names, so no one else can hold them. A name that is reserved on the gateway still works in the Names Browser.

The full list is RESERVED_LABELS in reserved.mjs. Another gateway may reserve different labels. Reserving is not part of the protocol: it is how one operator keeps its own hostnames from being used for phishing.

Subdomains and future subnames (non-normative). One label per host matches today's registry: LNS names have no dots, so subnames such as blog.alice do not exist yet (section 4.1; planned in section 4.10). Multi-level hosts such as blog.alice.lnsweb.online are refused. If LNS adds subnames later, a two-level wildcard certificate (*.*.lnsweb.online) is a paid Cloudflare feature (Advanced Certificate Manager), whereas Cloudflare's free Universal SSL covers only one level (*.lnsweb.online). Encoding a subname into one label with a dash form such as blog--alice.lnsweb.online is the cheaper option for a gateway.

Planned host form. With the planned subnames of the 0.4 registry (section 4.10), the gateway would serve blog.alice at https://blog--alice.lnsweb.online/, under the existing one-level wildcard. lns://blog.alice stays the real address. The new registry will ban -- in new names, so the form cannot clash with a name. Not built yet.

8.3 Requests

8.4 Checks

For each request this gateway works in this order. It stops at the first failure.

  1. Host and path (8.2, 8.3). Failure: 404.
  2. Blocklist by name, before any work on the name (8.8). Failure: 451.
  3. Record. Derive the name's accounts and read the record from the LEZ sequencer (section 4.2). No record: 404, "LNS name … was not found."
  4. Owner switch. gateway=off in the record: 404 (8.7).
  5. Root. If the record has a cid, it must also have a valid cid.sha256, or the answer is 502. A blocked root hash is 451. The root is fetched from Logos Storage (at most 2 MiB for a list or manifest) and hashed. If there is no cid, the on-chain page is read instead: at most 80 KiB, and under 10,240 bytes if it is a root list. No site at all: 404, "does not have a published website yet."
  6. Root form (section 5.9). A list must parse. A single-file root must be HTML or plain text, or the answer is 415. Plain text is shown inside a minimal HTML page.
  7. Walk. Each folder list on the path is fetched, hashed against the entry above it, and parsed. An entry with no SHA-256 is refused with 502. A missing path is 404.
  8. File. Fetched, size-checked and hashed against its entry. A mismatch is 502, "Content SHA-256 did not match its pinned hash." A blocked file or folder hash is 451.
  9. Render (8.5) and send.

The whole file is read and hashed before the response starts, so a bad file never sends a partial body. Storage timeouts are 504, and a CID that just timed out gets 504 at once for 30 seconds instead of another wait.

8.5 What it sends

8.5.1 Content types

This gateway chooses the Content-Type of every file in a site from the file's extension only. It never uses a manifest's contentType, a Storage header or content sniffing for them. (A single-file root, section 5.9, is checked by sniffing or by its on-chain content type, but only to decide whether it is HTML or plain text; it is then always sent as HTML.)

ExtensionSent as
.html .htmtext/html; charset=utf-8, sanitized (8.5.2)
.csstext/css; charset=utf-8, sanitized
.svgimage/svg+xml; charset=utf-8, sanitized
.png .jpg .jpeg .gif .webp .avif .icothe matching image/ type
.woff .woff2 .ttf .otfthe matching font/ type
.mp3 .ogg .wav .mp4 .webmthe matching audio/ or video/ type
.txt .mdtext/plain; charset=utf-8
.jsonapplication/json; charset=utf-8
.js .mjstext/plain; charset=utf-8 as a download (Content-Disposition: attachment), so the source can never load as a script
.lgx .wasm .zip .tar .gz .pdf .dmg .exe .apk and other archives and installersa download
.xhtml .xht .xml .xsl .xslt .shtml .svgz .mhtml .mhtrefused with 415
anything elseapplication/octet-stream as a download

8.5.2 Pages

HTML, CSS and SVG are sanitized to enforce the same script-free, self-contained rules as the Names Browser (section 7.1.1), while letting ordinary browsers draw standard HTML and CSS outside the Names Browser's rendering subset (section 7.10.1). In short: scripts, event handlers, frames, objects, meta refreshes and outside subresources are removed, and the CSP stops forms from submitting. Links are rewritten:

The gateway writes the page frame itself: its own <html>, <head> and <body>, a protecting stylesheet first in the head, then a CSP meta tag, then the page's own head content. The banner is the first child of <body>, so no page element can wrap it. It reads:

User site: lns://alice · verified 46e9b7064d5f · from CID      Open in LNS Browser   Report abuse

The hash is the first 12 hex digits of the root's SHA-256 (the full hash is in its tooltip). "from chain" replaces "from CID" for an on-chain root. The banner's look is set by inline !important styles, which outrank any page stylesheet. The protecting stylesheet blocks transforms, filters, clips and similar tricks on <html> and <body>. Page z-index values are clamped below the banner's, and attributes that would open the top layer, such as popover, are removed.

8.5.3 Headers

HeaderValue
Content-Security-Policy (HTML)default-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; media-src 'self'; script-src 'none'; connect-src 'none'; object-src 'none'; frame-src 'none'; frame-ancestors 'none'; form-action 'none'; base-uri 'none'; sandbox allow-downloads
Content-Security-Policy (SVG)default-src 'none'; style-src 'unsafe-inline'; img-src 'none'; script-src 'none'; frame-ancestors 'none'; sandbox
Content-Security-Policy (other files)default-src 'none'; frame-ancestors 'none'; sandbox
X-Content-Type-Optionsnosniff
Strict-Transport-Securitymax-age=31536000; includeSubDomains (no preload), on every response. Cloudflare sends the same header on the apex lnsweb.online and on every host of that zone.
Referrer-Policyno-referrer
X-Frame-OptionsDENY
Cross-Origin-Opener-Policysame-origin
Permissions-Policycamera, microphone, geolocation, payment, USB and motion sensors all off
X-Robots-Tagnoindex, nofollow, unless the owner sets gateway.index=on (8.7)
Access-Control-Allow-Origin* on CSS, images, fonts and media only; never on HTML, JSON or scripts

The sandbox directive gives every page an opaque origin, with no scripts and no form submission. This gateway never sends Set-Cookie, and the profile removes <meta http-equiv>, so a page cannot set one either.

8.6 Caching

This gateway sits behind a CDN and tells it what to keep with Cache-Control:

ResponseCache-Control
Pages and files at their normal pathpublic, max-age=60, s-maxage=120, stale-while-revalidate=300, stale-if-error=86400
/_imm/<sha256>/…public, max-age=31536000, immutable
404 and other "not here" answerspublic, max-age=300, s-maxage=300
451 (removed)public, max-age=300, s-maxage=3600
405, 5xx, busy, and a 404 under /_imm/no-store

Each 200 response has an ETag, and a matching If-None-Match gets 304. A file's ETag comes from its SHA-256 (for HTML, from the root's and the page's). For HTML, CSS and SVG it also carries the sanitizer revision (-s3), so an upgraded sanitizer is never answered with a stale 304.

Inside the process, this gateway keeps a name's record for 60 seconds. If the RPC fails it keeps using the last record for up to 24 hours. Verified lists, files and rendered pages are kept in memory caches with byte limits.

When a change shows. After a publish, the gateway sees the new record within 60 seconds and the CDN drops HTML within 120 seconds, so a change usually shows within about three minutes. A /_imm/ URL names one exact file, so it never goes stale. When a new root appears, the old root's /_imm/ files stay available for 10 minutes, so a page already loading can finish.

Purge after publish. This is an operator feature. When lns publish runs with the gateway's CDN purge token and admin token (section 9.3), it purges the CDN for the URLs it changed. It first calls the gateway's POST /_admin/invalidate, so the gateway forgets the old record before the CDN asks again. That call is accepted only from the same machine, only with a bearer token, and only when the operator has set one. An ordinary publisher has neither token, so the purge does nothing and the timings above apply.

8.7 Owner settings

This gateway serves every valid, unreserved LNS name that has a site, with no sign-up. An owner controls it with two text entries in the record:

EntryEffect
gateway=offThe gateway answers 404, "The owner of lns://… disabled the HTTPS gateway." The site still works in the Names Browser.
gateway.index=onThe gateway leaves out X-Robots-Tag: noindex, nofollow, so search engines may index the site.

Set them with the names CLI, for example names profile alice --set gateway=off. Values are compared without case and surrounding spaces. Changes take effect within the 60-second record cache and 120-second CDN cache (about three minutes), or at once if the operator purges the cache.

8.8 Takedowns and abuse

Site owner removal. A name owner can take their own site off the gateway at any time by setting gateway=off in the record (section 8.7) or clearing the record's cid and on-chain page. The change reaches visitors within about three minutes (section 8.6). If an owner needs an urgent cache purge or operator block, they can use the abuse page below.

Reporting abuse. Every page's banner and every error page has a "Report abuse" link to https://nameswallet.app/abuse, with the name (and on pages, the short root hash) filled in. That page is a static page with plain reporting instructions and no backend form; include the LNS name, the URL and the root SHA-256. The operator can point the link elsewhere with GATEWAY_ABUSE_URL.

Blocklist. The operator keeps a blocklist file (JSON or line-based text) with three parts:

A blocked request gets 451 "Site removed". The file is reloaded within about a second of a change, or at once on SIGHUP; if the file is briefly missing or invalid while being edited, the gateway keeps its last valid list during a 10-second grace window before clearing it. When an entry is added, the gateway drops what it has cached for the affected sites and, if a purge token is set, asks the CDN to purge the affected URLs. Blocking by hash means a takedown follows the content: it holds even if the owner points another name at the same bytes.

A takedown only stops this gateway from serving the content (and lets the operator delete locally held illegal material from their own Storage node). The site stays on chain and on any other Logos Storage node that still holds it, and the Names Browser keeps showing it. A gateway cannot change what an LNS name points to.

8.9 Load limits

A request for a new name costs one Argon2id derivation (64 MiB of memory), and every file costs a Storage fetch. This gateway limits both at the origin. All numbers are defaults that the operator can change.

LimitDefault
Names that already resolvedkept in a known-names index on disk when GATEWAY_KNOWN_NAMES_FILE is set (this deployment sets it), so they skip the derivation after a restart
Derivations for unknown namesat most 2 at once, 16 waiting; beyond that, 503 "Gateway busy" with Retry-After
RPC lookups for unknown names20 a second; 5 s timeout per RPC call
Names known not to existremembered for 5 minutes, up to 50,000
Storage downloads8 at once, at most 2 per site; queues of 256, at most 16 per site, served in turn
One file shown inline (HTML, CSS, SVG, images, fonts, media)10 MiB
One download25 MiB
Root or folder list2 MiB
On-chain page80 KiB
Storage fetch timeout2 s local check, then 10 s network fetch; then 504, and 30 s before the same CID is tried again
Whole request30 s; at most 256 concurrent HTTP connections
Process memory caches4,096 site records, 4,096 derived keys, 2,000 folder lists (16 MiB), 64 MiB blobs, 4,096 rendered pages (32 MiB)

A file over a size limit gets 413, "Open it in LNS Browser instead." Two requests for the same file share one download.

In front of the origin, the CDN serves cached answers and ignores the query string, so ?x=1 cannot bypass the cache. An edge firewall rule drops requests that are not GET or HEAD, Punycode and nested hosts, reserved labels, and common scanner paths.

Not yet protected. There is no edge rate limit on site hostnames (finding G35, open). A flood costs nothing at the CDN, but requests that miss the cache use the origin's bandwidth and CPU, held back only by the limits above.

8.10 Deployment and cost

The live gateway at *.lnsweb.online is deployed behind Cloudflare with no per-request compute tier:

Trust and cost trade-off. Putting Cloudflare in front keeps the public gateway at zero marginal hosting cost, at the price of trusting Cloudflare with TLS termination and in-transit content (section 8.12). Anyone who does not want Cloudflare in the path can open the site directly in the Names Browser or run their own gateway.

8.11 Shared domain

Every site on this gateway is a subdomain of lnsweb.online, a domain used only by the gateway. The main Names Wallet site is on a different registrable domain, nameswallet.app, so browsers no longer treat a user site as part of it. lnsweb.online is not on the Public Suffix List yet: a request is planned but not yet submitted. Until an entry is accepted, browsers treat all *.lnsweb.online sites as one registrable domain ("same site") among themselves. In practice:

Reduced, not closed (finding G7). This belongs to this deployment, not to the protocol. The move to lnsweb.online on 27 November 2026 removed the risk between user sites and the wallet site. The risk between user sites stays until lnsweb.online is listed in the Public Suffix List. Until then, this gateway runs no page scripts, sends a sandbox CSP, and never sends Set-Cookie on any response (tested in test/subdomains.test.mjs). Section 10.5.3 has more.

8.12 Trust

The gateway checks every byte against the record, but it cannot check the record. It trusts its RPC (here lez.nameswallet.app) to return a name's real record, just as the Names Browser trusts its own RPC (section 6.11).

Not yet protected. A dishonest or broken RPC could point a name at other content, and the gateway would serve that content with "verified" in the banner. "Verified" here means "matches the record the gateway's RPC returned" (section 10.4).

A visitor also trusts the gateway operator and the TLS front end (here Cloudflare), which could change any page. The banner's hash lets a visitor compare the root with what the Names Browser shows for the same name. For the full checks, open lns://<name> in the Names Browser with your own RPC. Section 10.3.2 lists everything a gateway visitor trusts.