From 53fc977ff04e0d13c2c35f31c51f16234cd3ba9f Mon Sep 17 00:00:00 2001 From: Jonathan Mohrbacher Date: Wed, 2 Dec 2026 17:57:24 -0500 Subject: [PATCH 1/2] gamebox: tinyproxy fallback egress for devbox's TeamClaude (allowlist api.anthropic.com, platform.claude.com) devbox's route to Cloudflare-fronted api.anthropic.com went dark in 20-70 s clusters for two hours on 2026-12-02 (Cloudflare DME site). gamebox egresses from the US and reaches a different Cloudflare site, so it is an independent path. CONNECT-only on 443, devbox's tailnet address only, anchored domain allowlist; reachable only over tailscale0 (port not opened on other interfaces). Bead workstation-dkts.3. --- flake.nix | 1 + hosts/gamebox/tc-fallback-proxy.nix | 54 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 hosts/gamebox/tc-fallback-proxy.nix diff --git a/flake.nix b/flake.nix index ea05ad5e..78d49120 100644 --- a/flake.nix +++ b/flake.nix @@ -4213,6 +4213,7 @@ ./hosts/gamebox/disko.nix ./hosts/gamebox/streaming.nix ./hosts/gamebox/em-ci.nix + ./hosts/gamebox/tc-fallback-proxy.nix ]; }; diff --git a/hosts/gamebox/tc-fallback-proxy.nix b/hosts/gamebox/tc-fallback-proxy.nix new file mode 100644 index 00000000..7c375a05 --- /dev/null +++ b/hosts/gamebox/tc-fallback-proxy.nix @@ -0,0 +1,54 @@ +# Fallback egress for devbox's TeamClaude: a CONNECT-only proxy that devbox can +# use (TeamClaude "upstreamProxy") when its own route to Cloudflare-fronted +# api.anthropic.com is broken. On 2026-12-02 devbox's (Hetzner HEL1) traffic to +# Cloudflare anycast landed on Cloudflare's Moscow site and went dark in +# 20-70 s clusters for two hours; gamebox egresses from the US and reaches a +# different Cloudflare site (EWR), so it is a path that fails independently. +# Bead workstation-dkts.3. +# +# Exposure: only devbox may use it, and only for the two hosts TeamClaude needs +# (the API, and platform.claude.com for OAuth token refresh), only on 443. +# - Listen is the wildcard on purpose: binding the tailnet address races +# tailscaled at boot and a failed bind wedges the unit. Reachability is +# instead bounded by the firewall: port 8888 is NOT in allowedTCPPorts, and +# only tailscale0 is a trusted interface (configuration.nix), so the guest +# Wi-Fi cannot reach it. +# - Allow: devbox's tailnet address only. Everything else gets 403. +# - Filter + FilterDefaultDeny: an anchored allowlist (domain match; for +# CONNECT tinyproxy matches the requested host). +# The tunnel is end-to-end TLS (TeamClaude speaks TLS to Anthropic through the +# CONNECT), so this box never sees tokens or prompts. +{ pkgs, ... }: + +let + devboxTailnetIp = "100.73.94.25"; + filter = pkgs.writeText "tc-fallback-proxy-filter" '' + ^api\.anthropic\.com$ + ^platform\.claude\.com$ + ''; +in +{ + services.tinyproxy = { + enable = true; + settings = { + Listen = null; # wildcard; see the exposure note above + Port = 8888; + Allow = devboxTailnetIp; + ConnectPort = 443; + Filter = "${filter}"; + FilterType = "ere"; + FilterDefaultDeny = true; + # TeamClaude streams long responses; an idle tunnel must survive a slow + # model turn. + Timeout = 900; + MaxClients = 64; + DisableViaHeader = true; + LogLevel = "Connect"; + }; + }; + + # Restart=on-failure with the default 100 ms delay can trip the start-limit + # on a transient error and leave the proxy dead; back off instead. + systemd.services.tinyproxy.serviceConfig.RestartSec = "5s"; + systemd.services.tinyproxy.unitConfig.StartLimitIntervalSec = 0; +} From d8586ad33d318f9194c678e2f382ad8324950f4c Mon Sep 17 00:00:00 2001 From: Jonathan Mohrbacher Date: Wed, 2 Dec 2026 18:02:49 -0500 Subject: [PATCH 2/2] gamebox tc-fallback-proxy: fatal bind, URL-mode filter pinned to :443, MaxClients 256 Listen 0.0.0.0 (explicit) so a failed v4 bind is fatal and restarts, instead of tinyproxy coming up on [::] only. FilterURLs with host:443 patterns so plain HTTP proxying is refused too (ConnectPort does not cover it). Bead workstation-dkts.3. --- hosts/gamebox/tc-fallback-proxy.nix | 39 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/hosts/gamebox/tc-fallback-proxy.nix b/hosts/gamebox/tc-fallback-proxy.nix index 7c375a05..0a534a07 100644 --- a/hosts/gamebox/tc-fallback-proxy.nix +++ b/hosts/gamebox/tc-fallback-proxy.nix @@ -6,16 +6,23 @@ # different Cloudflare site (EWR), so it is a path that fails independently. # Bead workstation-dkts.3. # -# Exposure: only devbox may use it, and only for the two hosts TeamClaude needs -# (the API, and platform.claude.com for OAuth token refresh), only on 443. -# - Listen is the wildcard on purpose: binding the tailnet address races -# tailscaled at boot and a failed bind wedges the unit. Reachability is -# instead bounded by the firewall: port 8888 is NOT in allowedTCPPorts, and -# only tailscale0 is a trusted interface (configuration.nix), so the guest -# Wi-Fi cannot reach it. -# - Allow: devbox's tailnet address only. Everything else gets 403. -# - Filter + FilterDefaultDeny: an anchored allowlist (domain match; for -# CONNECT tinyproxy matches the requested host). +# Exposure: only devbox may use it, only CONNECT, only for the two hosts +# TeamClaude needs (the API, and platform.claude.com for OAuth token refresh), +# only on 443. +# - Listen 0.0.0.0, not the tailnet address: binding 100.x races tailscaled +# at boot. Explicit (not unset) so a failed bind is fatal and the unit +# restarts until it binds; with Listen unset tinyproxy starts "successfully" +# on [::] alone when the v4 bind fails. Reachability is bounded by the +# firewall: port 8888 is NOT in allowedTCPPorts and only tailscale0 is +# trusted (configuration.nix), so the guest Wi-Fi cannot reach it; the +# em-ci containers' egress fence drops host-local destinations. +# - Allow: devbox's tailnet IPv4 only; everything else gets 403. If devbox is +# re-registered on the tailnet this address changes and the fallback +# answers 403 exactly when it is needed: update it here. +# - FilterURLs + anchored host:443 patterns + FilterDefaultDeny: the filter +# runs on the request target, which for CONNECT is "host:port" and for +# plain-HTTP proxying starts with "http://", so plain HTTP is refused by +# construction (ConnectPort alone does not cover it). # The tunnel is end-to-end TLS (TeamClaude speaks TLS to Anthropic through the # CONNECT), so this box never sees tokens or prompts. { pkgs, ... }: @@ -23,25 +30,29 @@ let devboxTailnetIp = "100.73.94.25"; filter = pkgs.writeText "tc-fallback-proxy-filter" '' - ^api\.anthropic\.com$ - ^platform\.claude\.com$ + ^api\.anthropic\.com:443$ + ^platform\.claude\.com:443$ ''; in { services.tinyproxy = { enable = true; settings = { - Listen = null; # wildcard; see the exposure note above + Listen = "0.0.0.0"; # see the exposure note above Port = 8888; Allow = devboxTailnetIp; ConnectPort = 443; Filter = "${filter}"; + FilterURLs = true; FilterType = "ere"; FilterDefaultDeny = true; # TeamClaude streams long responses; an idle tunnel must survive a slow # model turn. Timeout = 900; - MaxClients = 64; + # TeamClaude opens one tunnel per upstream request (no keep-alive pool); + # at the limit tinyproxy spins and queues rather than refusing, so leave + # ample headroom. Threads are cheap. + MaxClients = 256; DisableViaHeader = true; LogLevel = "Connect"; };