Skip to content

feat(platform): reach other websites through a round-robin proxy pool - #5053

Merged
yannickmonney merged 1 commit into
mainfrom
feat/outbound-proxy-pool
Oct 26, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
feat/outbound-proxy-pool

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

VIDEO_INGEST_PROXY_URL was the platform's only proxy setting, and only video ingestion read it, so every other request Tale made to another website left from the deployment's own address. This adds OUTBOUND_PROXY_URLS: a list of HTTP proxies that every request to another website takes in turn (round robin). That covers the website crawler, registering a website, the chat assistant's web_fetch, the remote images an email draws, video ingestion, and every connection a sandbox session opens to the internet. VIDEO_INGEST_PROXY_URL stays, now as the video-only override. Nothing changes unless it is set: a deployment that sets neither variable sends every request the way it did before.

What changes

Lane How it takes the pool
safeFetch callers: crawler (robots, sitemaps, link walk, pages), website registration (robots.txt, homepage), web_fetch, email images the next proxy per request, opted in with outboundProxy: true
yt-dlp VIDEO_INGEST_PROXY_URL when set; otherwise the next pooled proxy per run (--proxy), so a run extracts and downloads through one address
sandbox egress (tinyproxy) a local squid hop on 127.0.0.1:3129 rotates the pool per connection (cache_peer … round-robin, never_direct allow all)
  • The value. http://[user:password@]host[:port] entries, comma- or whitespace-separated, in @tale/shared/net/outbound-proxies. The grammar is narrow on purpose: http:// only (what undici, yt-dlp and squid all speak), credentials percent-encoded with printable-ASCII escapes, at most 128 bytes together (squid's MAX_LOGIN_SZ; past it squid crashes on the first request), a host name or IPv4 address, and an optional port. Boot (the zod env) and the egress service's start refuse a malformed entry, naming its position and never its text, which can carry a password. The egress image reads the list with outbound-proxies.awk; outbound-proxies.guard.test.ts runs both readers over the same entries and lists and holds them identical.
  • Rotation and failure (lib/net/outbound-proxy.ts). Requests take the proxies in turn, counted per process. A proxy that can't be reached, or that refuses its credentials (a tunnel answered 407), is passed over for 60 s and logged once by host and port. The request then goes once more through the next proxy. A request never falls back to a direct connection, even when every proxy is passed over. A destination's own refusal (a forwarded 407, a tunnel 502, a TLS stall) blames no proxy, and an error names the proxy it went through.
  • What stays direct. Private destinations a deployment allows (TALE_ALLOW_PRIVATE_CRAWL_HOSTS): each hop is routed on its own. Also every service a deployment configures itself (AI providers, connectors, SSO, storage), which never opts in.
  • The egress fence. With the hop in place, tinyproxy dials only squid, so the iptables rules no longer see destinations. squid holds the fence itself: the cache manager is closed (it would show the parents' decoded passwords), and private destinations, IPv6 literals and names that don't resolve are refused. Its config is 0600, read as root before squid serves as the squid user. The entrypoint supervises squid beside tinyproxy and dnsmasq, and squid runs only when the list names a proxy. An IPv6-only destination is refused by design, and the docs say so.
  • Docs. docs/{en,de,fr}/self-hosted/: a new "Outbound proxies" section in configuration/environment-reference.md, plus configuration/video-ingestion.md, install/kubernetes.md and operate/observability/troubleshooting.md. Also .env.example, services/sandbox-egress/README.md, services/sandbox/docs/incus.md, and a commented example in the CLI's generated env. No UI string, so no message catalog changes.
  • Manual boxes. KNOW-F40, KNOW-B27, TASK-F95, TASK-B55, VID-F9 (new); VID-F6 reworded.

Dormancy

With OUTBOUND_PROXY_URLS unset, safeFetch builds no proxy route, so every request goes direct as before. yt-dlp gets --proxy only from VIDEO_INGEST_PROXY_URL, as before. The egress service renders no Upstream and starts no squid. Tests hold each of these: safe-fetch-proxy.test.ts, ytdlp.test.ts, and the "egress proxy outbound proxies" suite in egress-proxy-config.test.ts.

Checklist

  • bun run check: format:check, lint:conflicts and lint:links pass, and so do 45 of its 49 turbo tasks across two local runs (every lint and typecheck; @tale/shared 1,108 tests, @tale/cli 3,829, @tale/sandbox, @tale/docs, @tale/web). The Mac ran at a load average of 45 to 130 with other sessions' builds beside it. The other four failed only on time, in files this change doesn't touch: wall-clock budgets in @tale/platform (such as "diffs each pair in under 5 ms" at 13.7 s), 5 s timeouts in test:ui and @tale/sandbox-runtime-daemon, and in @tale/ui a different test on each run (two 5 s timeouts, then a code-editor test that reads the partial syntax tree CodeMirror parses within its time budget). On GitHub's runners, this head's Unit lanes (platform 1/2 and 2/2, workspaces), Type check, Lint, Knip and Format all pass.
  • bun run lint:sast (Opengrep): CI's Opengrep and Opengrep OSS pass on this head; the pre-commit Opengrep pass over the staged files passed too.
  • Translations: N/A for the message catalogs. No key is added; the one changed sentence is the render lane's halt reason, a server-side string outside the catalogs. The user docs are updated in docs/{en,de,fr}/, French with its non-breaking spaces.
  • Docs updated in docs/{en,de,fr}/.
  • README.md / README.de.md / README.fr.md: N/A. The root READMEs list no environment variables; services/sandbox-egress/README.md is updated.

Test plan

Local, bun 1.4.2:

  • The new and changed suites, run on their own: @tale/shared outbound-proxies.test.ts, 58 pass (the grammar, every refusal, no password in a message). @tale/platform, 426 pass over eight files:

    • outbound-proxy.test.ts: rotation, set-aside, revival.
    • safe-fetch-proxy.test.ts, against real local proxies: rotation; routing per hop; failover on an unreachable proxy and on a 407; no blame for a forwarded 407, a 502 tunnel or a TLS stall.
    • safe-fetch.test.ts.
    • ytdlp.test.ts: override versus pool; a stand-in yt-dlp whose pooled proxy fails sets it aside.
    • env.test.ts: the boot refusal names the position, never the password.
    • crawl-parse.test.ts.
    • outbound-proxies.guard.test.ts: the TypeScript and awk readers agree on 89 entries and lists; the docs and .env.example carry the variable.
    • turbo-inputs.guard.test.ts.

    @tale/sandbox egress-proxy-config.test.ts, 43 pass: the squid rendering, the ACL order, 0600, supervision, a log line that names hosts only, the FATAL on a malformed entry, and the unchanged rendering when the variable is unset.

  • bunx knip exit 0; oxlint and the type check are in the gate above.

  • By hand, in a Docker lab on the Mac, removed afterwards. The production egress image ran in front of two real squid upstreams:

    • HTTPS went out through both in turn.
    • A stopped proxy was passed over, then taken back after 60 s.
    • 22 attempts to get around the fence were refused: private ranges, IPv6 literals, the cache manager, names that don't resolve.
    • The production limits held.

    The backend lanes were also driven through real proxies with undici.

Not run, and not claimed:

  • The merge queue's jobs. Build: the egress image was built locally in the lab. CLI: its unit tests pass. Backend integration and E2E are left to the queue; nothing here touches the database or the UI, and with the variable unset every path is the previous direct one.
  • A commercial proxy plan in front of a deployed environment: that comes with the ops wiring.

Ops follow-up

Nothing here is used until an environment sets the variable. After a release carries it, ops wires OUTBOUND_PROXY_URLS the way VIDEO_INGEST_PROXY_URL is wired: the tale.json mapping, each deploy workflow's service_secrets, the secret catalogue, and the Incus egress instance's environment. That pays off the ops ledger's entry for "only the video downloader goes through the proxy". A draft of that change is prepared in the ops repository and not pushed.

OUTBOUND_PROXY_URLS lists HTTP proxies, comma- or whitespace-separated,
and every request Tale makes to another website takes them in turn: the
website crawler (robots, sitemaps, pages), registering a website (its
robots.txt and homepage), the chat assistant's web_fetch, the remote
images an email draws, video ingestion (yt-dlp, one proxy per run) and
every connection a sandbox session opens to the internet.
VIDEO_INGEST_PROXY_URL, when set, still takes video ingestion out of the
rotation.

The backend rotates per request and passes over a proxy it cannot reach,
or that refuses its credentials, for 60 s; a request whose proxy failed
goes once more through the next one, and none falls back to a direct
connection. Private destinations (the allowed intranet hosts) stay
direct, and so do the services a deployment configures itself
(providers, connectors, SSO, storage). The sandbox egress service hands
its traffic to a local squid hop, since tinyproxy keeps one upstream;
squid rotates the pool per connection and holds the fence the firewall
held before: no cache manager, no private or IPv6-literal destination,
nothing unresolvable.

Two readers parse the value, the shared TypeScript module and the egress
service's awk, and a guard holds them identical. A malformed entry stops
the backend's boot and the egress service's start, naming its position,
never its password.
auto-merge was automatically disabled October 26, 2026 20:24

Pull request was closed

@yannickmonney yannickmonney reopened this Oct 26, 2026
auto-merge was automatically disabled October 26, 2026 20:29

Pull request was closed

@yannickmonney yannickmonney reopened this Oct 26, 2026
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 505810c Oct 26, 2026
190 of 207 checks passed
@yannickmonney
yannickmonney deleted the feat/outbound-proxy-pool branch October 26, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant