Portal your localhost to the multiverse!
TunnelRick is a reverse proxy tunneling service (similar to ngrok) that allows you to expose your local development servers to the internet. Built with Node.js, TypeScript, Express, and WebSockets.
cd client
chmod +x install.sh
./install.shAfter installation, use the tunnelrick command:
tunnelrick -s wss://tunnelrick.coffee -k '7b0dd27a-4456-43cf-aee1-a93c3026a976' -p 3000Parameters:
-s- Server URL (the WebSocket address of the TunnelRick server)-k- API Key (your authentication key for the server)-p- Port (the local port to expose, change this to your app's port)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β INTERNET β
β β
β User visits: https://tunnel.example.com/t/{tunnelId}/your-api-path β
βββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β
β HTTP Request
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TUNNELRICK SERVER β
β (Your Cloud/VPS Instance) β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β β
β β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββ β β
β β β Express HTTP β β WebSocket β β MySQL β β β
β β β Server βββββββΊβ Server βββββββΊβ Database β β β
β β β β β β β β β β
β β β Routes: β β - Auth β β - api_keys β β β
β β β /t/:tunnelId/* β β - Messages β β - tunnels β β β
β β β /health β β - Connections β β β β β
β β βββββββββββββββββββ ββββββββββ¬βββββββββ βββββββββββββββ β β
β β β β β
β βββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β
β WebSocket Connection
β (Persistent, Bidirectional)
β
ββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β YOUR LOCAL MACHINE β
β βββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ β
β β βΌ β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β TUNNELRICK CLIENT β β β
β β β (CLI Tool) β β β
β β β β β β
β β β - Maintains WebSocket connection to server β β β
β β β - Receives incoming HTTP requests β β β
β β β - Forwards requests to local server β β β
β β β - Sends responses back through tunnel β β β
β β β β β β
β β ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ β β
β β β β β
β β β HTTP Forward β β
β β βΌ β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β YOUR LOCAL DEV SERVER β β β
β β β β β β
β β β http://localhost:3000 β β β
β β β (React, Express, Django, etc.) β β β
β β β β β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Before setting up TunnelRick, ensure you have the following installed:
- Node.js (v16 or higher)
- npm or yarn
- MySQL (v8.0 or higher) - for the server
- A VPS/Cloud server with a public IP and domain (for production)
- Linux or macOS - Windows users need WSL or Git Bash
The server is the central hub that receives requests from the internet and routes them to connected clients.
cd servernpm installCreate a MySQL database and user:
CREATE DATABASE tunnelrick;
CREATE USER 'tunnel_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON tunnelrick.* TO 'tunnel_user'@'localhost';
FLUSH PRIVILEGES;The required tables will be created automatically when the server starts.
Copy the example environment file and edit it:
cp .env.example .envEdit .env with your settings:
PORT=3000
DOMAIN=tunnel.yourdomain.com
NODE_ENV=production
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=tunnel_user
MYSQL_PASSWORD=your_secure_password
MYSQL_DATABASE=tunnelrickDevelopment:
npm run devProduction:
npm run build
npm startWith PM2 (recommended for production):
npm install -g pm2
pm2 start ecosystem.config.jsRun the migration to create the required tables:
mysql -u tunnel_user -p tunnelrick < migrations/001_init.sqlInsert API keys into the database for client authentication:
USE tunnelrick;
INSERT INTO api_keys (key_value, name) VALUES ('your-secret-api-key', 'My API Key');The client runs on your local machine and creates a tunnel to expose your local server.
The client comes pre-built and ready to use. Just extract and install:
# Extract the client package
unzip tunnelrick-client.zip
cd client
# Run the installer
./install.shThe installer will:
- Copy files to
~/.tunnelrick - Set up the
tunnelrickcommand - Add to your PATH (optional)
After installation, restart your terminal or run:
source ~/.bashrc # or ~/.zshrcIf you prefer to build from source:
cd client
npm install
npm run build
./install.shBasic usage:
tunnelrick -s wss://tunnel.yourdomain.com -k your-api-key -p 3000All options:
tunnelrick [options]
Options:
-s, --server <url> Tunnel server WebSocket URL (required)
-k, --key <apiKey> API key for authentication (required)
-p, --port <port> Local port to forward traffic to (required)
-t, --tunnel-id <id> Custom tunnel ID (optional, auto-generated if not provided)
-H, --host <host> Local host to forward to (default: "localhost")
-h, --help Display helpExamples:
# Expose local React app running on port 3000
tunnelrick -s wss://tunnel.example.com -k my-api-key -p 3000
# Use a custom tunnel ID
tunnelrick -s wss://tunnel.example.com -k my-api-key -p 8080 -t myapp
# Forward to a different local host
tunnelrick -s wss://tunnel.example.com -k my-api-key -p 3000 -H 192.168.1.100Once connected, you'll receive a public URL like:
https://tunnel.yourdomain.com/t/abc12345/
Any requests to this URL will be forwarded to your local server.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CONNECTION PHASE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. Client starts and connects to server via WebSocket β
β β
β 2. Client sends AuthMessage: β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β { β β
β β "type": "auth", β β
β β "apiKey": "your-api-key", β β
β β "tunnelId": "custom-id" (optional) β β
β β } β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β
β 3. Server validates API key against MySQL database β
β β
β 4. Server responds with AuthSuccessMessage: β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β { β β
β β "type": "auth_success", β β
β β "tunnelId": "abc12345", β β
β β "url": "https://domain.com/t/abc12345" β β
β β } β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β
β 5. Tunnel is now active and ready for requests! β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Secure Authentication - API key-based authentication stored in MySQL
- Custom Tunnel IDs - Use your own tunnel ID or let the system generate one
- All HTTP Methods - Supports GET, POST, PUT, DELETE, PATCH, etc.
- HTML Asset Rewriting - Automatically rewrites relative URLs in HTML responses
- Request Timeout - 60-second timeout for pending requests
- Colorful CLI Output - Rick and Morty themed terminal output