Deploy Nahan Gateway to Cloudflare
Deploy directly from your browser to Cloudflare Workers or Pages. Automatically creates the required Cloudflare D1 database (nahan-db), binds IOT_DB, enables nodejs_compat, and publishes the gateway.
1 Cloudflare Credentials & Configuration
⚙️ Advanced Gateway Options (D1 Database, Master Key, Route) ▼
Deployment Console
Your Nahan Gateway v3.1.0 is live and ready.
📖 Overview & Architecture
Comprehensive overview of Project Nahan Gateway v3.1.0 capabilities
⚡ Dual Protocols
Seamless VLESS and Trojan protocol demuxing over Cloudflare WebSockets with native cloudflare:sockets TCP connection pipelining.
🛡️ Self-Healing Relays
Automated two-stage TLS liveness checks (4s/7s), passive failover quarantine, AI traffic segregation, and Graveyard burial with auto-resurrection.
📦 Multi-Client Configs
Automated generation for Clash Meta/Mihomo, Sing-box, V2Ray/Xray, and URI format with per-country auto-selectors and flag emojis.
Modular Code Architecture (All Files < 650 lines)
| File / Module | Lines | Description |
|---|---|---|
| worker.js | 279 | Primary fetch dispatcher, WebSocket upgrade, maintenance proxy |
| src/config.js | 231 | System defaults, circuit breaker, bounded fetchT, byte math |
| src/crypto.js | 132 | Pure SHA-224 hash engine, Trojan password cache, UUID encoders |
| src/db.js | 321 | D1 SQLite integration, runner lock leases, audit logging |
| src/relays.js | 631 | Two-stage TLS probes, quarantine maps, graveyard resurrection |
| src/tunnel.js | 537 | Socket pipelining, VLESS & Trojan parsing, byte tracking |
| src/subs/transformers.js | 608 | Unified proxy transformer, clean IP math, fragmentation params |
| src/subs/generators.js | 352 | Subscription exporters (Clash YAML, Singbox, V2Ray, URI) |
| src/telegram/bot.js | 417 | Bilingual Telegram bot webhook, inline keyboards, alert notifications |
💡 Operations Wiki & Client Setup
Technical manual for relay configuration, client apps, and anti-censorship parameters
📱 Client Apps & Subscription Import
Copy your subscription link from the dashboard or telegram bot and import directly into your client:
🤖 AI Smart Egress Tagging (`#AI`)
To prevent ChatGPT, Claude, and Gemini from blocking Cloudflare datacenter egress IPs, append #AI to clean residential or VPS relay endpoints:
When clients access AI domains (openai.com, gemini.google.com, etc.), Nahan Gateway automatically prioritizes #AI relays.
💻 Wrangler CLI Deployment
Commands for terminal-based local development and production deployment
1. Initialize and Create D1 Database
npx wrangler login
npx wrangler d1 create nahan-db
2. Update wrangler.toml with your database ID
name = "nahan-gateway"
main = "worker.js"
compatibility_date = "2024-03-01"
compatibility_flags = ["nodejs_compat"]
[[d1_databases]]
binding = "IOT_DB"
database_name = "nahan-db"
database_id = "YOUR_DATABASE_UUID_FROM_STEP_1"
3. Deploy to Cloudflare
npm run deploy
# or: npx wrangler deploy