cloudflared tunneling service.
Overview
Cloudflare tunnels create a secure HTTPS connection from your local Maestro instance to the internet without exposing your IP address or requiring port forwarding.Tunnels are ideal for accessing Maestro from anywhere, sharing sessions with team members, or accessing from mobile devices outside your local network.
Prerequisites
Starting a Tunnel
Maestro automatically manages the tunnel lifecycle:Tunnel Starts Automatically
Maestro starts
cloudflared and waits for the tunnel URL (max 30 seconds)Tunnel Status
Check tunnel status programmatically:API Reference
start(port: number)
Start a new tunnel to the specified local port.Local port number to tunnel (1-65535)
Whether tunnel started successfully
Public HTTPS URL (only present if success is true)
Error message (only present if success is false)
stop()
Stop the currently running tunnel.SIGTERM and has 3 seconds to gracefully shutdown before receiving SIGKILL.
getStatus()
Get current tunnel status.Whether tunnel is currently active
Public HTTPS URL (null if not running)
Last error message (null if no errors)
Error Handling
The tunnel manager handles common error scenarios:cloudflared not installed
cloudflared not installed
Error:
cloudflared is not installedSolution: Install cloudflared using the instructions in PrerequisitesInvalid port number
Invalid port number
Error:
Invalid port number: {port}Solution: Port must be between 1 and 65535Tunnel startup timeout
Tunnel startup timeout
Error:
Tunnel startup timed out (30s)Solution: Check network connectivity and try again. The timeout may occur on slow connections.Connection refused
Connection refused
Error:
Connection refusedSolution: Ensure the web server is running on the specified port before starting the tunnelImplementation Details
The tunnel manager spawnscloudflared as a child process:
cloudflared (uses system PATH or configured custom path)['tunnel', '--url', 'http://localhost:{port}']URL Detection
The manager parsescloudflared’s stderr output to extract the tunnel URL:
Cloudflare outputs the URL to stderr (not stdout). Maestro accumulates buffer chunks to handle URLs split across multiple writes.
Process Lifecycle
- Start: Spawn
cloudflaredwith tunnel args - Monitor: Listen for URL in stderr output (30s timeout)
- Running: Keep process alive and maintain URL reference
- Stop: Send SIGTERM, wait 3s, then SIGKILL if needed
src/main/tunnel-manager.ts:1
Security Considerations
HTTPS by Default
All tunnel URLs use HTTPS with Cloudflare’s TLS certificates
Temporary URLs
Free trycloudflare.com URLs are temporary and change on restart
No IP Exposure
Your local IP address is never exposed to the internet
Token Required
Access still requires Maestro’s security token from the web server
Advanced: Custom cloudflared Path
Ifcloudflared is not in your system PATH, Maestro will attempt to locate it in common installation directories. You can also specify a custom path in Maestro’s configuration.
Source: src/main/utils/cliDetection.ts