00001 — Static Website Deployment Architecture
The site is static Astro output hosted on Cloudflare Pages (ADR-001), with media in a Cloudflare R2 bucket (ADR-002). Every edge setting below is declared in the site’s OpenTofu module, deploy/modules/site/, and applied the same way to non-production and production. Requirement IDs refer to SR-009 unless stated.
1. Request path

Each environment has its own zone: <test-domain> for non-production and <domain> for production. Two addresses are served in each zone:
<domain>(andwww) is the Pages project, which holds the builtdist/folder and nothing else.assets.<domain>is the media bucket, attached to the zone as a custom domain.
Both addresses pass the same TLS settings and firewall rules, because both are in the same zone.
2. Components
| Component | Responsibility | Declared in | Requirements |
|---|---|---|---|
| DNS | A record for the host pointing at the Pages project, and www pointing at the host. The media address’s record is created by Cloudflare when the bucket’s custom domain is attached. |
dns.tf |
— |
| Zone baseline | TLS and HSTS, Cloudflare’s managed rules, two custom firewall rules, a per-client rate limit over the whole zone, and the threat settings, from the shared site module. Described once in Zone Baseline. | tls.tf, waf.tf, security.tf |
SR-INFRA-008 |
| Pages project | Hosts one environment’s built site. Deployed by direct upload from the pipeline, so Cloudflare needs no access to the repository. It exposes no separate origin. | pages.tf |
SR-001 SR-F-02, SR-F-03; SR-009 SR-F-05 |
| Media bucket | Holds the site’s public images. Served only at assets.<domain>; its r2.dev address is turned off, so media cannot be reached around the zone. |
storage.tf |
SR-009 SR-F-04 |
| Security headers | X-Frame-Options, X-Content-Type-Options, Referrer-Policy and a Content-Security-Policy on every page, and a one-year immutable cache on /_astro/*. |
public/_headers, rewritten by scripts/write-headers.mjs at build |
SR-009 SR-F-02, SR-F-03 |
3. Read flow
- The reader’s browser asks for
https://<domain>/.... Plain HTTP is redirected to HTTPS. - The zone applies the managed ruleset, the custom rules, the rate limit and the threat settings. A request that fails any of them is blocked at the edge and never reaches Pages or the bucket.
- A page request is answered by the Pages project, through Cloudflare’s cache.
- The page’s images point at
https://assets.<domain>/images/..., so the browser fetches them from the media bucket through the same zone. - Every page response carries the security headers. The policy allows images from the media address and each inline script by its hash.
4. Content-Security-Policy
The policy is computed per build, not written by hand. npm run build runs astro build, then scripts/write-headers.mjs rewrites the policy line in dist/_headers:
img-srcadds the origin of the environment’s media address.script-srclists the SHA-256 hash of every inline script indist/, never'unsafe-inline'.style-srckeeps'unsafe-inline', because highlighted code blocks carry inline styles a hash cannot cover.- Fonts, icons and analytics are allowed from their named hosts only.
The build fails when the policy passes the length Pages allows for one header.
5. Non-production and production
Both environments call the same module with different inputs: hostname, zone, Pages project, media bucket, HSTS age and rate-limit threshold. The only difference in shape is an expiry rule on the non-production media bucket, which keeps test media inside the free storage limit. The infrastructure is applied by the layers described in Layered Environments.
6. Cost and failure behaviour
- Cost: hosting, bandwidth, the managed ruleset, the custom rules and the rate limit run on the free plan, and R2 has no egress charge, so a traffic flood cannot produce a bill (BRD-001 BR-1.1, BR-1.2).
- Traffic surge: pages and media are cached at the edge, so load does not reach a single origin (BRD-001 BR-3.2).
Related Documents
- BRD-001 — Secure, Low-Cost Public Website Hosting
- BRD-007 — Layered Edge Security
- SR-001 — Static Website Deployment
- SR-009 — Layered Security Controls
- ADR-001 — Astro Static Generation on Cloudflare Pages
- 00002 — Media Asset Delivery Architecture
- 00003 — Delivery Pipeline Architecture
- 00004 — Infrastructure Pipeline Architecture
- 00005 — Access Boundaries Architecture
- Zone Baseline