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:
- 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. - Refuse the apex (
lnsweb.onlineitself) and any host outside the domain. - What is left before
.<domain>must be exactly one label.a.b.lnsweb.onlineis refused. - Refuse a label that starts with
xn--(Punycode), so a browser never shows it as a look-alike Unicode name. An LNS name such asxn--abcis valid, but this gateway does not serve it. - The label must be a valid LNS name: 1 to 32 characters of
a-z,0-9and-, not starting or ending with-(section 4.1). - 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:
- Infrastructure:
www,mail,api,rpc,cdn,static,gateway,status,admin,mta-stsand others (38). - Trust, account and abuse words:
abuse,report,legal,terms,privacy,security,support,login,auth,account,verify,officialand others (21). - Common phishing lures:
claim,airdrop,reward,refund,download,recovery,seed,connect,walletconnect,kyc,update,release,storage,docs,betaand others (41).
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
- Methods. GET and HEAD only. Anything else gets 405 with
Allow: GET, HEAD. The one exception is an operator call,POST /_admin/invalidate, accepted only from the same machine with a token (section 8.6). - Query and fragment. Ignored. They play no part in resolution (section 5.7).
- One spelling per file. The path must be in canonical form: no empty segments except a trailing
/, no.or.., no encoded/, and each segment percent-encoded exactly as the gateway itself would encode it. Any other spelling, such as%62rowserforbrowser, is a 404. This keeps one CDN cache entry per file. - Resolution. A canonical path is resolved through the lists as in section 5.7, so
/docsand/docs/both serve the folder's index. - Hashed asset paths.
/_imm/<sha256>/<filename>serves one file of the current site by its hash. The hash must be 64 lower-case hex digits, and the filename must be that file's own name. The gateway writes these URLs itself when it rewrites a page's stylesheets, images and fonts (section 8.5), and only for files it has already seen in a verified list of the site.
8.4 Checks
For each request this gateway works in this order. It stops at the first failure.
- Host and path (8.2, 8.3). Failure: 404.
- Blocklist by name, before any work on the name (8.8). Failure: 451.
- 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."
- Owner switch.
gateway=offin the record: 404 (8.7). - Root. If the record has a
cid, it must also have a validcid.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 nocid, 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." - 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.
- 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.
- 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.
- 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.)
| Extension | Sent as |
|---|---|
.html .htm | text/html; charset=utf-8, sanitized (8.5.2) |
.css | text/css; charset=utf-8, sanitized |
.svg | image/svg+xml; charset=utf-8, sanitized |
.png .jpg .jpeg .gif .webp .avif .ico | the matching image/ type |
.woff .woff2 .ttf .otf | the matching font/ type |
.mp3 .ogg .wav .mp4 .webm | the matching audio/ or video/ type |
.txt .md | text/plain; charset=utf-8 |
.json | application/json; charset=utf-8 |
.js .mjs | text/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 installers | a download |
.xhtml .xht .xml .xsl .xslt .shtml .svgz .mhtml .mht | refused with 415 |
| anything else | application/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:
lns://bob/xbecomeshttps://bob.lnsweb.online/x; a link to the same name stays a local path.- A local stylesheet, image or font becomes its
/_imm/<sha256>/<filename>URL when the gateway already holds its verified folder list, and stays a plain path otherwise. https://links that pass the profile's checks stay as they are. Other schemes are dropped.
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
| Header | Value |
|---|---|
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-Options | nosniff |
Strict-Transport-Security | max-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-Policy | no-referrer |
X-Frame-Options | DENY |
Cross-Origin-Opener-Policy | same-origin |
Permissions-Policy | camera, microphone, geolocation, payment, USB and motion sensors all off |
X-Robots-Tag | noindex, 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:
| Response | Cache-Control |
|---|---|
| Pages and files at their normal path | public, 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" answers | public, 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:
| Entry | Effect |
|---|---|
gateway=off | The gateway answers 404, "The owner of lns://… disabled the HTTPS gateway." The site still works in the Names Browser. |
gateway.index=on | The 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:
names: LNS names. Checked first, before the record is read.rootsandblobs: SHA-256 hashes. A blocked root removes the whole site. A blocked file or folder list removes that file, or everything under that folder.
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.
| Limit | Default |
|---|---|
| Names that already resolved | kept 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 names | at most 2 at once, 16 waiting; beyond that, 503 "Gateway busy" with Retry-After |
| RPC lookups for unknown names | 20 a second; 5 s timeout per RPC call |
| Names known not to exist | remembered for 5 minutes, up to 50,000 |
| Storage downloads | 8 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 download | 25 MiB |
| Root or folder list | 2 MiB |
| On-chain page | 80 KiB |
| Storage fetch timeout | 2 s local check, then 10 s network fetch; then 504, and 30 s before the same CID is tried again |
| Whole request | 30 s; at most 256 concurrent HTTP connections |
| Process memory caches | 4,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:
- A domain of its own.
lnsweb.onlineis a separate registrable domain used only by the gateway. A proxied wildcard DNS record (*.lnsweb.online) points to the gateway's Cloudflare Tunnel. The apexlnsweb.onlineredirects to this specification atweb.lnsweb.online. The Names Wallet site stays onnameswallet.app, with its abuse page (nameswallet.app/abuse), the browser download (nameswallet.app/browser) and the RPC (lez.nameswallet.app), so user sites never share a domain, hosting or build artifacts with the main site. - Moved on 27 November 2026. Until then the gateway served
<name>.nameswallet.app. Those addresses now redirect permanently (301) to<name>.lnsweb.online, keeping the path and query, so old links keep working.lez.nameswallet.app(the RPC) andwww.nameswallet.appare not redirected. The gateway's setting is nowGATEWAY_DOMAIN=lnsweb.online; nothing else in the gateway changed. - Edge TLS, cache and WAF. Cloudflare's edge terminates TLS using free Universal SSL (Full (strict), Always Use HTTPS). A free Cache Rule makes HTML eligible for CDN caching, honours the origin's
Cache-Controlheaders (section 8.6) and ignores query strings. A free WAF rule drops non-GET/HEAD methods, malformed, Punycode or multi-level hosts, hosts longer than 46 characters (a 32-character name plus.lnsweb.online), reserved labels and common scanner paths at the edge before they reach the origin. The new zone has the same TLS, HSTS, cache and firewall settings as the old one. - Outbound-only tunnel to origin. Cache misses travel over a Cloudflare Tunnel (
cloudflared) to the Node 24 gateway process (serve.mjs, zero npm dependencies) running on a machine we run next to a local Logos Storage node. The tunnel is outbound-only, so the host needs no open inbound port. The gateway checks its local loopback Storage node first (2 s timeout) before falling back to the wider Storage network (10 s). - No Cloudflare Worker, by design. Cloudflare Workers bill per request, including responses served from cache, so a traffic flood can run up a bill. Edge redirects, CDN cache hits, edge-blocked WAF requests and Cloudflare Tunnel traffic carry zero marginal cost. Even under a flood, Cloudflare does not bill for the traffic; requests that miss the cache hit only the bounded origin limits in section 8.9.
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:
- A cookie set for the whole domain would reach every user site. This gateway never sets cookies, and the CSP sandbox and the profile stop pages from setting them.
- Browser features that trust "same site" requests treat one user site as the same site as another.
- A bad site can hurt
lnsweb.online's reputation with browser safe-browsing lists, and so every other user site on it, but no longer the wallet site. The banner, reserved labels and blocklist are there to limit this.
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.