Repository navigation
feat(cloudflare_worker): relay listed APIs through one Cloudflare Worker, replacing telegram_relay - #116
Merged
Conversation
…er, Telegram as one of its modes A host that reaches Cloudflare but not an API needs the same Worker the Telegram relay was: a fixed upstream and a list of paths it may reach, so the Worker is no open proxy. The role keeps one module for both: `relay` mode takes the upstream and path prefixes as they are, `telegram` mode builds them from the bot ids. telegram_relay goes, as it was never released.
hackallcode
commented
Nov 21, 2026
…d APIs share one hostname
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Telegram relay is one case of a wider need: a host that reaches Cloudflare but not some API can call it through a
Worker that knows what it may reach. A vendor cloud API throttled on the host's network is the next one, and a role
per API, each with its own Worker, hostname and copy of the upload tasks, would drift and put every relayed API in
public DNS and certificate logs.
cloudflare_workerreplacestelegram_relaywith one Worker for any number of upstreams. The first path segmentnames the upstream host:
/<host>/<path>goes tohttps://<host>/<path>, with method, headers, query and body, whenthe host is a key of
cloudflare_worker_upstreamsand the path starts with one of its prefixes. A client takeshttps://<hostname>/<host>as the upstream's base URL. The Telegram Bot API needs no mode of its own: it is theupstream
api.telegram.orgwith/bot<id>:and/file/bot<id>:of the allowed bots as prefixes, and its clients(Alertmanager's
api_url, python-telegram-bot'sbase_url) accept a base URL with a path.Every other call gets 404, so the Worker is no open proxy. The check runs on the normalised URL path and on the exact
host key, so
..segments,user@host, a port or an unlisted host do not slip through. The upload, thedeploy-<hash>tag, the hostname handling,uninstalland--checkbehave as intelegram_relay; the tag now hashesthe upstreams. Detaching a hostname answers 204, which
telegram_relaytook for a refusal, so a renamed hostname or anuninstallfailed after the detach went through.telegram_relaywas never released, so it goes without a deprecation step. A deployed one keeps running until itsclients move to the new base URL and
uninstalldeletes it by name. The Worker tests move tomake test/cloudflare-worker, and the CI step follows.