Skip to Content
LYNKORIADocs

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

HostRecordProxyServesManaged by
api.lynkoria.comCNAME → App Platform default ingressProxiedREST, Socket.IO, LiveKit webhooksplatform
console.lynkoria.comCNAME → Pages project + Pages custom domainProxied + AccessOperator consoleplatform
lynkoria.com (apex)CNAME (flattened) → Pages project + custom domainProxiedLanding page, docs, /.well-known/security.txtplatform
rtc.lynkoria.comA → media DropletDNS onlyLiveKit signalling (WSS) and WebRTC mediaplatform
turn.lynkoria.comA → media DropletDNS onlyTURN over TLS (443)platform
scanner.internal.lynkoria.comA → scanner private IPDNS onlyScanner certificate name (VPC only)platform
www.lynkoria.comAAAA 100:: placeholder + redirect ruleProxied301 to https://lynkoria.com, keeps path and queryzone
_dmarc.lynkoria.comTXT v=DMARC1; p=reject; …—Reject spoofed mailzone
lynkoria.com CAAletsencrypt.org, pki.goog, iodef—Limit certificate issuerszone
Staging: api-staging, console-staging, staging, rtc-staging, turn-staging, scanner-staging.internalSame as aboveSameStagingplatform (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.com host. Never add a plain-HTTP subdomain. Add preload and 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:

  1. The zone stack generates one secret per environment (random_password.origin_secret).
  2. Its http_request_late_transform ruleset sets x-lynkoria-origin-secret on requests to each API host ("set" overwrites any client value).
  3. The platform stack reads that secret from the zone state and stores it as the app's CF_ORIGIN_SECRET.
  4. The API answers 403 forbidden to everything except /health/* without the header, refuses WebSocket upgrades, and in production refuses to start with CLIENT_IP_HEADER=cf-connecting-ip but 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).

  • Email Routing for security@ and support@ (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/livekit if the WAF ever blocks signed LiveKit payloads. These can be added to the zone stack as further cloudflare_ruleset resources.
  • 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-ray

The console must show the Access login first, and a Socket.IO client and a TURN-forced call must connect through these hosts.

On this page