↓ Skip to main content
  1. Posts/

Aggregate Multiple Proxy Subscriptions into One Gateway: Cloudflare + Sub-Store + Clash Auto-Routing

·458 words·3 mins· loading · loading · ·
HJP
Author
HJP
Always learning, always growing.
Table of Contents

This is an English summary of the Chinese article. All keys, domains, and tokens below are placeholders <...> — replace them with your own.

What problem this solves
#

Holding several proxy subscriptions usually means: uneven node quality, daily manual switching between clients, and no clean way to share with family. This guide shows a “three-in-one subscription gateway”: one subscription link, imported into Clash, with automatic routing by site type.

Architecture
#

Cloud sync Worker (periodically fetch upstream subs → merge → slim → store in KV)
        ↓
Gateway (Sub-Store on Cloudflare Pages)
  ├─ /api/file/full   → full subscription (admin-token protected)
  └─ /guest/<token>   → guest subscription (for family/friends)
        ↓
Clash / Clash Verge imports subscription → auto-routing

You maintain only one subscription link. Upstream subscriptions are aggregated on Cloudflare.

Cloudflare resources needed
#

ResourceTypeRole
GatewayPagesRuns Sub-Store, serves the subscription
Sync WorkerWorkerCron (e.g. every 6h) fetches upstream, merges, updates KV
KVKVSub-Store data / sync results
Nav pagePagesHuman-facing entry (contains no secrets)

The nav page exposes only buttons (copy subscription, jump to backend, sync status). No passwords, no token-bearing links — this isolation prevents accidental credential leaks via screenshots.

Steps
#

  1. Aggregate subscriptions — add each upstream sub in Sub-Store, then combine them into one collection. (Note: some subs are behind Cloudflare JS Challenge; fetch locally or with a rotating cf_clearance cookie.)
  2. Design proxy groups — the core of auto-routing. Daily use needs zero changes; rules already route for you. Know just 4 groups: 🔓 Smart Unlock (AI/streaming), 🌐 Save-Traffic (YouTube/Google), 🎛️ Master Switch (force one node), 🏠 HK Residential (best unlock).
  3. Import into Clash — paste https://<your-gateway>/<admin-token>/api/file/full. Guests use https://<sync-worker>/guest/<token>.
  4. Automate sync — Cloud Worker Cron every 6h; optional local fallback script (most reliable way to fetch all nodes when upstreams block the cloud).

Security boundaries (critical for public deployment)
#

  1. Admin token protects the full subscription.
  2. Nav page carries zero secrets.
  3. Guest tokens are isolated and revocable.
  4. Real credentials never reach the client.
  5. Config changes must stay in sync between local generator and cloud Worker.

Common troubleshooting
#

SymptomCause / Fix
403 “Just a moment” on fetchJS Challenge → refresh cookie
Node count drops (only no-cookie upstream)Cookie expired → refresh
429 on syncFree Browser Rendering quota exhausted (~10 min/day) → wait for reset
Nav page unreachableCheck Pages project + CNAME

Summary
#

Aggregating multiple subscriptions into “one gateway + auto-routing” is essentially using Cloudflare as a merge-and-scheduler layer: upstream = multiple subs, middle = Worker sync + Sub-Store, downstream = Clash routes by rule, user-unaware. The whole setup is free (Cloudflare Free is enough for personal/small-group use); main upkeep is the weekly cookie refresh and keeping the local fallback alive.

Full Chinese version: /posts/multi-sub-gateway/

Related