Expand description
In-process CloudFront data plane.
Mirrors the ELBv2 data plane (fakecloud-elbv2/src/dataplane.rs): a
supervisor loop binds one TcpListener on 127.0.0.1:0 per enabled
distribution, records the OS-allocated port back into distribution state as
bound_port, and serves viewer requests via hyper. The AWS-shaped
*.cloudfront.net domain stays cosmetic; clients discover the real address
via /_fakecloud/cloudfront/distributions and connect to
http://127.0.0.1:{bound_port}/....
handle_request 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.
Functions§
- dataplane_
enabled - Whether the data plane should run. Disabled by setting
FAKECLOUD_CLOUDFRONT_DISABLE_DATAPLANEto a truthy value (mirrors the ELBv2 flag), for environments that only exercise the control plane. - spawn_
dataplane - Spawn the CloudFront data-plane supervisor. No-op (returns without spawning)
when disabled via the env flag.
server_portis fakecloud’s own listen port, used to reach S3-website origins served by this process.