Skip to main content

Module dataplane

Module dataplane 

Source
Expand description

In-process CloudFront data plane.

Distributions are served on fakecloud’s main --addr listener, routed by the request Host header, rather than on a per-distribution ephemeral port. CloudFrontDataPlane::serve is installed as an outer middleware on the main axum router: it matches the Host header against every enabled distribution’s DomainName (<id>.cloudfront.net) or one of its alternate domain names (Aliases/CNAMEs). A match is served as viewer traffic; anything else (the AWS API, /_fakecloud/*, health) is handed straight back for normal dispatch.

This is how real CloudFront works – a distribution is reached by its domain, not a port – and it means a distribution is reachable from outside a container whenever the main port is published (-p), with no second listener to expose. Clients discover which distributions are served, and the domain to send as Host, via /_fakecloud/cloudfront/distributions.

Once a request is matched to a distribution, serve selects a cache behavior by path pattern, resolves its origin, reverse-proxies to it, and applies CustomErrorResponses (e.g. the SPA 404 -> /index.html served as 200). There is no global edge network – this is a single local origin-serving node, matching the ALB/API Gateway precedent. Deferred (not implemented): in-path CloudFront Functions / Lambda@Edge, TTL caching / invalidation, and OAC/SigV4 to private S3.

Structs§

CloudFrontDataPlane
The CloudFront data plane: serves enabled distributions on the main listener, routed by Host. Constructed once at server startup and installed as an outer middleware; see CloudFrontDataPlane::serve.

Functions§

dataplane_enabled
Whether the data plane should serve viewer traffic. Disabled by setting FAKECLOUD_CLOUDFRONT_DISABLE_DATAPLANE to a truthy value (mirrors the ELBv2 flag), for environments that only exercise the control plane. Also drives the served flag surfaced via /_fakecloud/cloudfront/distributions.