Bore with Subdomain Routing
A complete solution for running bore with ngrok/localtunnel-style subdomain routing and automatic HTTPS via Cloudflare.
┌──────────────────────────────────────────────────────────────┐
│ User types: https://happy-cat.local.mcp-use.run │
└─────────────────────────┬────────────────────────────────────┘
│ HTTPS (Cloudflare handles SSL)
│
┌─────────────────────────▼────────────────────────────────────┐
│ Cloudflare (Free SSL + DDoS) │
└─────────────────────────┬────────────────────────────────────┘
│ HTTP
│
┌─────────────────────────▼────────────────────────────────────┐
│ HTTP Proxy (subdomain routing) │
│ happy-cat → localhost:8123 │
└─────────────────────────┬────────────────────────────────────┘
│
┌─────────────────────────▼────────────────────────────────────┐
│ Bore Server (TCP tunnels) │
└─────────────────────────┬────────────────────────────────────┘
│ Tunnel
│
┌─────────────────────────▼────────────────────────────────────┐
│ Bore Client (user's local machine) │
│ bore local 3000 --to server.com │
└─────────────────────────┬────────────────────────────────────┘
│
┌─────────────────────────▼────────────────────────────────────┐
│ Local Web Server (port 3000) │
└──────────────────────────────────────────────────────────────┘
🌟 Features
- ✨ Subdomain routing -
happy-blue-cat.local.mcp-use.run style URLs
- 🔒 Automatic HTTPS - Free SSL via Cloudflare
- 🔐 Token-based authentication - Prevents port scanning and tunnel hijacking
- 🛡️ Path restrictions - Configurable path restrictions (default:
/mcp** and /mcp-use**, or allow all paths with /)
- 🌐 WebSocket support - Full bidirectional communication
- 🎯 REST API - Simple tunnel management
- 📦 NPX client - No installation needed for clients
- 🐳 Docker ready - Easy deployment
- 🚀 Railway/Render compatible - Deploy in minutes
📦 What's Included
This repository contains:
@mcp-use/tunnel - NPX client for bore tunnels (no Rust needed!)
proxy-server - HTTP proxy with subdomain routing
- Cloudflare integration - HTTPS without managing certificates
- Complete deployment guides - Railway, Docker, VPS, etc.
🚀 Quick Start
Server Setup (5 minutes)
Option 1: Railway (Easiest)
Option 2: Docker
cd proxy-server
docker-compose up -d
See DEPLOYMENT.md for more options.
Client Usage
python -m http.server 3000
npx @mcp-use/tunnel 3000
curl https://happy-blue-cat.local.mcp-use.run
Railway Deployments (Custom Control Port)
Railway exposes TCP ports with random external ports (e.g., caboose.proxy.rlwy.net:23894 → :7835). The server includes a custom bore build with --control-port support.
⚠️ Important: The tunnel ports (8000-9000) that bore assigns are NOT externally accessible - they're only used internally by the HTTP proxy on Railway. Users access tunnels via subdomain URLs (e.g., https://happy-cat.local.mcp-use.run), not direct port access.
The API response includes the correct connection command:
curl https://your-domain.com/api/tunnels
Usage with Railway:
The mcp-tunnel command automatically uses the correct server configuration:
export BORE_SERVER=caboose.proxy.rlwy.net
export BORE_CONTROL_PORT=23894
npx @mcp-use/tunnel 3000
Note: The package includes custom bore binaries with --control-port support built-in.
📚 Documentation
❓ FAQ
Do I need to handle HTTPS in my app?
No! If you use Cloudflare (recommended), it handles SSL termination. Your app only needs HTTP (port 80).
See: CLOUDFLARE-SETUP.md
How is this different from ngrok?
| Subdomain routing | ✅ | ✅ | ✅ |
| Custom domains | ✅ (paid) | ✅ | ✅ (free) |
| Self-hostable | ❌ | ✅ | ✅ |
| HTTPS | ✅ | ✅ | ✅ (via Cloudflare) |
| Free tier limits | 40 req/min | None | None (self-hosted) |
| Written in | Go | Node.js | Rust + Node.js |
How much does it cost?
- Cloudflare: FREE ✅
- Domain: ~$10/year
- Railway: ~$5/month (500 hours free tier)
- Total: ~$10/year + optional $5/month
Or self-host on a $4-6/month VPS!
Can I use my own domain?
Yes! Any domain works. Just configure DNS and Cloudflare:
- Point
*.local.your-domain.com to your server
- Set
BASE_DOMAIN=local.your-domain.com
- Configure Cloudflare for free HTTPS
See: CLOUDFLARE-SETUP.md
🏗️ Architecture
Components
Data Flow
User Request (HTTPS)
→ Cloudflare (SSL termination)
→ HTTP Proxy (subdomain routing)
→ Bore Tunnel (TCP proxy)
→ Bore Client (user's machine)
→ Local Service
🛠️ Development
Prerequisites
- Node.js 18+
- Rust (for building bore)
- Docker (optional)
Local Development
cd proxy-server
yarn install
yarn start
docker-compose up
Project Structure
mcp-use-tunnel/
├── bore/ # Bore source code (Git submodule)
├── proxy-server/ # HTTP proxy with subdomain routing
│ ├── index.js # Main proxy server
│ ├── package.json
│ ├── Dockerfile
│ └── docker-compose.yml
├── cli.js # NPX bore wrapper
├── package.json # bore-npx package
├── CLOUDFLARE-SETUP.md # Cloudflare guide
├── DEPLOYMENT.md # Deployment guide
└── README.md # This file
🔒 Security Features
- ✅ Token-based authentication - Prevents port scanning attacks
- ✅ IP-based validation - Prevents token theft
- ✅ Path restrictions - Only
/mcp** and /mcp-use** paths allowed
- ✅ Rate limiting - Prevents API abuse
- ✅ Connection limits - Prevents resource exhaustion
- ✅ Automatic cleanup - Expired tunnels removed automatically
- ✅ Pre-assigned ports - No random port scanning possible
See SECURITY.md for details.
🤝 Contributing
Contributions welcome! Some ideas:
📝 License
MIT
🙏 Credits
🔗 Links
📧 Support
Made with ❤️ for the developer community