Cloudflare Worker + Durable Objects — WebSocket proxy for Telegram MTProto connections.
Allows browser-based Telegram clients (like Telegram Web A (MOD)) to connect to Telegram servers through Cloudflare's network when direct WebSocket connections are blocked.
Click the button above → authorize your Cloudflare account → done. Your worker will be deployed automatically.
Browser (GramJS) → wss://your-worker.workers.dev/pluto.web.telegram.org/apiws → Telegram Server
- Browser connects to your Cloudflare Worker via WebSocket
- Worker creates a Durable Object that holds a persistent WebSocket to Telegram
- All messages are bridged bidirectionally: browser ↔ Worker ↔ Telegram
Once deployed, set your worker domain in the Telegram Web A (MOD) proxy settings:
Proxy Domain: tg-ws-api.your-account.workers.dev
Or set it as an environment variable during build:
PROXY_URL=tg-ws-api.your-account.workers.dev
| Route | Description |
|---|---|
GET / |
Health check (JSON) — includes DC mapping info |
wss://<domain>/<telegram-host>/<path> |
WebSocket proxy to Telegram |
wss://<domain>/pluto.web.telegram.org/apiws |
Example: proxy to DC1 (pluto) |
Durable Objects are automatically placed near the target Telegram DC for lowest latency using Cloudflare Location Hints.
| Telegram DC | Hosts | Physical Location | CF Location Hint |
|---|---|---|---|
| DC1 (Pluto) | zws1.web.telegram.org |
Miami, USA | enam |
| DC2 (Venus) | zws2.web.telegram.org |
Amsterdam, NL | weur |
| DC3 (Aurora) | zws3.web.telegram.org |
Miami, USA | enam |
| DC4 (Vesta) | zws4.web.telegram.org |
Amsterdam, NL | weur |
| DC5 (Flora) | zws5.web.telegram.org |
Singapore | apac |
- Automatic: The worker detects which Telegram DC you're connecting to and places the DO near it
- Manual Override: Add
?locationHint=<hint>to force a specific region
wss://your-worker.workers.dev/zws2.web.telegram.org/apiws → Auto: weur (Amsterdam)
wss://your-worker.workers.dev/zws5.web.telegram.org/apiws → Auto: apac (Singapore)
wss://your-worker.workers.dev/zws1.web.telegram.org/apiws?locationHint=wnam → Override: wnam
| Hint | Region |
|---|---|
wnam |
Western North America |
enam |
Eastern North America |
sam |
South America |
weur |
Western Europe |
eeur |
Eastern Europe |
apac |
Asia Pacific |
oc |
Oceania |
afr |
Africa |
me |
Middle East |
Note: Location hints are soft preferences — Cloudflare tries its best but doesn't guarantee exact placement.
- Only proxies to
*.telegram.orgdomains (regex validated) - Each connection gets its own Durable Object instance
- CORS headers included for cross-origin browser access
- No data is stored — pure pass-through proxy
npm install
npx wrangler deploy- Worker: Routes requests, validates domains, handles CORS, auto-detects DC location
- Durable Object (
WebSocketProxy): Holds persistent WebSocket pairs (client ↔ upstream) - Location Hints: DOs placed near Telegram DCs for optimal latency
- No external dependencies: Pure Cloudflare Workers runtime
For higher performance and limits, upgrade to the paid plan.
Paid plan benefits:
- ⚡ Higher request limits — 10M+ requests/month (free: 100K/day)
- 🔄 More Durable Object operations — 1M+ included (free: 100K/day)
- 🌍 Global Durable Objects — lower latency worldwide
- 📊 Workers Analytics — detailed request metrics
- 🚀 No daily limits — consistent throughput
- 💾 More DO storage — 10GB included (free: 1GB)
MIT