Expand description
Externally visible request scheme, with proxy headers honoured only from a trusted proxy.
JSS derives the public scheme from X-Forwarded-Proto and, failing that,
the Cloudflare cf-visitor: {"scheme":"https"} header
(src/ap/index.js getProtocol 49-56 and src/ap/routes/actor.js 17-18).
Those headers are attacker-controlled unless a proxy that the operator
trusts overwrites them, and the scheme feeds the NIP-98 signed-URL check
and every absolute base URI the server mints. So here they are honoured
only when the operator sets the trusted-proxy flag
(--trust-proxy / JSS_TRUST_PROXY, default off). Without it the scheme
is the transport’s own: https when the listener terminates TLS, else
http.
Functions§
- effective_
scheme effective_scheme_withusing the server’s configured trusted-proxy flag (falsewhen the request carries noAppState).- effective_
scheme_ with - The request scheme as the client sees it.
- host_
allowed truewhenhost(ahost[:port]) is permitted byallowed, an empty list permitting everything. Entries match case-insensitively either the whole authority or just the host part.- host_
with - The authority a request should be treated as addressed to, with the configuration passed explicitly.
- normalise_
origin - Reduce a configured public base URL to its origin (
scheme://authority, no path, no trailing slash).Nonewhen it is not anhttp(s)URL with a usable authority. - proxy_
header_ scheme - Scheme named by the proxy headers, if any:
X-Forwarded-Protofirst (first element of a comma list), else theschememember of thecf-visitorJSON object. An unusableX-Forwarded-Protovalue falls through tocf-visitor. - request_
host host_withusing the server’s configured public origin and trusted-proxy flag.- request_
origin scheme://hostof the request. A configured public origin wins outright; otherwiseeffective_schemeplusrequest_host.- request_
url - The absolute URL the client addressed (origin plus request target), the
value a NIP-98
utag is signed over.