Cloudflare zone
Every Cloudflare record and setting for lynkoria.com, which OpenTofu stack manages it, and the few items that stay manual.
The lynkoria.com zone runs on Cloudflare. OpenTofu manages it: zone-wide items in infra/opentofu/zone/, per-environment items in infra/opentofu/platform/cloudflare.tf. Do not edit managed items in the dashboard; the next apply reverts them.
Host map
| Host | Record | Proxy | Serves | Managed by |
|---|---|---|---|---|
api.lynkoria.com | CNAME → App Platform default ingress | Proxied | REST, Socket.IO, LiveKit webhooks | platform |
console.lynkoria.com | CNAME → Pages project + Pages custom domain | Proxied + Access | Operator console | platform |
lynkoria.com (apex) | CNAME (flattened) → Pages project + custom domain | Proxied | Landing page, docs, /.well-known/security.txt | platform |
rtc.lynkoria.com | A → media Droplet | DNS only | LiveKit signalling (WSS) and WebRTC media | platform |
turn.lynkoria.com | A → media Droplet | DNS only | TURN over TLS (443) | platform |
scanner.internal.lynkoria.com | A → scanner private IP | DNS only | Scanner certificate name (VPC only) | platform |
www.lynkoria.com | AAAA 100:: placeholder + redirect rule | Proxied | 301 to https://lynkoria.com, keeps path and query | zone |
_dmarc.lynkoria.com | TXT v=DMARC1; p=reject; … | — | Reject spoofed mail | zone |
lynkoria.com CAA | letsencrypt.org, pki.goog, iodef | — | Limit certificate issuers | zone |
Staging: api-staging, console-staging, staging, rtc-staging, turn-staging, scanner-staging.internal | Same as above | Same | Staging | platform (staging) |
Media records have TTL 60 because a replaced media Droplet gets a new IP and OpenTofu updates the records in the same apply. rtc and turn must stay DNS only: Cloudflare's proxy does not carry WebRTC UDP or TURN, and Caddy must answer the ACME challenge itself.
The scanner record publishes a private (VPC) address on purpose. It is reachable only inside the VPC; the name lets a replacement scanner keep the same URL and certificate name.
SSL/TLS and network (zone stack)
- SSL/TLS mode Full (strict); Always Use HTTPS; minimum TLS 1.2; TLS 1.3 on.
- WebSockets on (Socket.IO is WebSocket-only).
- Rocket Loader and Email Obfuscation off (they break SDKs and webhooks).
- HSTS: the static sites send it with
includeSubDomains. Because the docs site is on the apex, browsers apply it to every*.lynkoria.comhost. Never add a plain-HTTP subdomain. Addpreloadand submit to hstspreload.org only once every subdomain, including staging, serves HTTPS.
Origin lock (API)
App Platform also serves the API at its *.ondigitalocean.app hostname, which skips Cloudflare; a client there could forge cf-connecting-ip. The API therefore requires a secret header that only the edge adds:
- The zone stack generates one secret per environment (
random_password.origin_secret). - Its
http_request_late_transformruleset setsx-lynkoria-origin-secreton requests to each API host ("set" overwrites any client value). - The platform stack reads that secret from the zone state and stores it as the app's
CF_ORIGIN_SECRET. - The API answers
403 forbiddento everything except/health/*without the header, refuses WebSocket upgrades, and in production refuses to start withCLIENT_IP_HEADER=cf-connecting-ipbut no secret.
The Deploy workflow checks the lock after every apply (the default ingress must return 403). Rotation: operate.
Caching (zone stack)
A cache rule bypasses cache for every API host. The API also sends no-store where it matters.
Access (platform stack)
Optional (enable_access, default on). Per environment, one self-hosted Access application covers the console host, api.<host>/v1/admin and the console's pages.dev preview hosts, with one audience (CF_ACCESS_AUD, passed to the app automatically). The allow policy lists ACCESS_ALLOWED_EMAILS. OPTIONS preflights bypass to the origin, which enforces the console origin. The rest of the API is never behind Access: product SDKs, sockets and webhooks must reach it.
With enable_access = false OpenTofu creates no Access resources and the API runs without CF_ACCESS_*: the console is protected by its own passwords, lockout and rate limits only, with no MFA. The Zero Trust organization, team domain and identity provider are created once by hand (step 2).
Still manual (optional, recommended before launch)
- Email Routing for
security@andsupport@(creates MX and SPF records; the zone stack does not manage those). - DNSSEC: enable in the dashboard and add the DS record at the registrar.
- WAF managed ruleset, and an edge rate-limiting rule for
POST /v1/admin/auth/login(for example 30 requests per minute per IP). Add a skip for/v1/webhooks/livekitif the WAF ever blocks signed LiveKit payloads. These can be added to the zone stack as furthercloudflare_rulesetresources. - Bot Fight Mode and "I'm under attack" must stay off for the API hosts.
Verify after changes
dig +short api.lynkoria.com rtc.lynkoria.com turn.lynkoria.com
curl -sI https://api.lynkoria.com/health/ready | grep -i cf-rayThe console must show the Access login first, and a Socket.IO client and a TURN-forced call must connect through these hosts.