Tunnel Setup
Configure ngrok tunnels for remote access to your DorkOS instance
Tunnel Setup
DorkOS includes optional ngrok tunnel support for accessing your instance from any device. The tunnel is non-blocking — if it fails to start, the server continues working locally.
Prerequisites
- An ngrok account (free tier works)
- An ngrok auth token from your ngrok dashboard
Quick Start
Set your ngrok auth token
export NGROK_AUTHTOKEN=your-token-hereOr paste it directly in the UI when you open the Remote Access dialog (see UI Toggle below).
Start DorkOS with tunneling enabled
dorkos --tunnelOr use the environment variable:
export TUNNEL_ENABLED=true
dorkosAccess the tunnel URL
The tunnel URL appears in the terminal output with a QR code you can scan on mobile.
UI Toggle
Start and stop the tunnel from the DorkOS interface without restarting the server:
- Click the Globe icon in the status bar
- Toggle Enable remote access on
- The tunnel URL and QR code appear when connected
The dialog also provides:
- Custom domain — Set a static ngrok domain so your URL stays consistent across restarts
- Connection quality indicator — Green/yellow/red dot showing latency to the tunnel
- Copy URL — Copy the tunnel URL to your clipboard
- Copy session link — Copy a direct link to the current session
Multi-Tab Sync
When DorkOS is open in multiple browser tabs, all tabs stay in sync with tunnel status. Changes in one tab are reflected in all others within about 1 second via BroadcastChannel.
Remote devices connected via the tunnel URL receive real-time status updates via SSE.
Custom Domains
ngrok offers free static domains that persist across restarts:
- Go to dashboard.ngrok.com/domains and claim a free domain
- Enter it in the Custom domain field in the Remote Access dialog, or set
TUNNEL_DOMAIN
Benefits:
- Same URL across restarts
- QR codes and bookmarks remain valid
Configuration
Prop
Type
Security
Tunnels expose your DorkOS instance to the public internet. Always protect your tunnel with basic auth.
export TUNNEL_AUTH=myuser:mypassword
export NGROK_AUTHTOKEN=your-token-here
dorkos --tunnelWith basic auth enabled, anyone accessing the tunnel URL is prompted for credentials before reaching DorkOS.
How It Works
Server starts normally
DorkOS starts the Express server on the configured port (default 4242).
Tunnel connects
After the server binds, the tunnel manager dynamically imports the @ngrok/ngrok SDK and creates a tunnel. Dynamic import means zero overhead when tunneling is disabled.
URL is available
The tunnel URL appears in the terminal with a QR code for mobile access. If tunnel creation fails, the server continues working locally.
Real-time status sync
The tunnel manager emits status events via EventEmitter. These are broadcast to all connected clients via SSE (GET /api/tunnel/stream) and across browser tabs via BroadcastChannel.
Graceful shutdown
When you stop the server (via SIGINT or SIGTERM), the tunnel closes automatically before the process exits.
API Endpoints
Control the tunnel programmatically:
# Start the tunnel
curl -X POST http://localhost:4242/api/tunnel/start
# Stop the tunnel
curl -X POST http://localhost:4242/api/tunnel/stop
# On-demand status check
curl http://localhost:4242/api/tunnel/statusHealth Check
When a tunnel is active, the health endpoint includes tunnel status:
curl http://localhost:4242/api/health{
"status": "ok",
"tunnel": {
"enabled": true,
"connected": true,
"url": "https://your-domain.ngrok-free.app"
}
}The tunnel field only appears in the health response when tunneling is enabled. Use GET /api/tunnel/status for full status including connection quality.
CLI QR Code
When a tunnel starts, the CLI prints a QR code:
DorkOS v0.8.0
Local: http://localhost:4242
Network: http://192.168.1.100:4242
Tunnel: https://your-domain.ngrok-free.app
Scan to open on mobile:
[QR Code]Development Mode
For development with tunnels, the tunnel targets the Vite dev server port (4241 by default) so HMR and proxied API calls work correctly:
pnpm --filter=@dorkos/server run dev:tunnelEmbedded Mode
When running as an Obsidian plugin, the tunnel UI is automatically hidden since tunneling does not apply in that context.
Troubleshooting
If the tunnel fails to start, verify your NGROK_AUTHTOKEN is valid and that you have not
exceeded your ngrok account's tunnel limit. The server continues running locally even if the
tunnel fails.
Common issues:
- "Tunnel is already running" — The server returns 409. Stop the existing tunnel first.
- Auth token not found — Ensure
NGROK_AUTHTOKENis exported in your shell, or paste it in the Remote Access dialog. - Custom domain errors — Verify your domain is claimed at dashboard.ngrok.com/domains.
- Connection quality red — High latency (>500ms) to the tunnel, usually caused by geographic distance to the ngrok edge server.
- Disconnected toast — If the tunnel drops unexpectedly, you will see a notification. The system attempts to reconnect automatically.