From 04cb22fd3bfcf91cd49b62ef44150901188dd6db Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sun, 10 May 2026 01:24:50 +0000 Subject: [PATCH] anubis: re-protect f1 with a per-host policy that allows JSON routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Earlier f1 revert left the host fully unprotected (no Anubis, exclude_crowdsec=true on the ingress already). Re-add Anubis with a custom policy_yaml that: - ALLOWs /_app/* (SvelteKit immutable JS/CSS chunks loaded before any cookie exists), /openapi.json, /docs, /api/* (FastAPI meta). - ALLOWs the 9 known JSON/proxy routes (schedule, streams, embed, embed-asset, extract, extractors, health, proxy, relay) so the SvelteKit SPA's XHRs return JSON instead of the challenge HTML. - Catch-all CHALLENGE for everything else — the SPA HTML pages (which fall through to FastAPI's `/{path}` catch-all) get the PoW gate. The ALLOWed JSON routes are technically scrapeable by a determined bot, but the user's stated goal is "avoid accidental scrapes" — the HTML/SPA is the AI-training target, and that stays gated. Verified: / → Anubis challenge HTML; /schedule, /streams → JSON; /_app/.../app.js → text/javascript; ClaudeBot UA → Anubis deny page. --- stacks/f1-stream/main.tf | 48 +++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/stacks/f1-stream/main.tf b/stacks/f1-stream/main.tf index 042e3b51..072a8bab 100644 --- a/stacks/f1-stream/main.tf +++ b/stacks/f1-stream/main.tf @@ -228,18 +228,56 @@ module "tls_secret" { } -# NOTE: f1-stream serves its SPA + JSON data endpoints (/schedule, /embed, -# /embed-asset, …) all on the same path tree, so putting Anubis in front -# breaks XHR data fetches with "Unexpected token '<', '