LightningWeb.ChannelProxyPlug (Lightning v2.19.0-pre)

View Source

Reverse proxy plug for channels.

Authenticates the inbound request against the channel's client auth methods, resolves destination credentials, and streams the request upstream via Philter.proxy/2. Request and response events are recorded as ChannelRequest / ChannelEvent records for auditing.

Request ID

An x-request-id header is forwarded to the destination for end-to-end tracing. If the caller provides one it will be used, but Plug.RequestId requires it to be between 20 and 200 characters — shorter or longer values are discarded and a new ID is generated automatically.

Response security headers

This plug is mounted at the endpoint above the router (LightningWeb.Endpoint) so that the raw request body survives for proxying, and it halts once the response is sent. The :browser pipeline — and with it put_secure_browser_headers/2 — is therefore never reached, so the headers it would have set are applied here instead. See secure_proxy_response/1.