Expose local development ports and sandboxed web apps over a single outbound WSS connection behind a cookie access gate, with built-in TLS and WebRTC STUN/TURN.
Tunnel is a self-hosted preview relay for machines and sandboxes that have no public IP and only outbound TCP 443. A single tunnel-server binary on a VPS terminates TLS (with automatic Let’s Encrypt DNS-01 certificates), enforces per-tunnel access gates, embeds an optional web dashboard, and includes a built-in STUN/TURN WebRTC relay—with no external reverse proxy or coturn required.
On your laptop or inside a sandbox, the tunnel client opens one outbound WebSocket (WSS) to tunnel-server and multiplexes every exposed port over Yamux. Visitors open https://{port}-{id}.previews.example.com, pass the gate on the zone host, and reach your local app over HTTP/1.1, HTTP/2, WebSockets, SSE, and WebRTC.
Note: Tunnel is currently pre-release targeting
1.0.0. Prebuilt release installers become live once thev1.0.0GitHub Release is published; until then, build from source with Cargo.
Architecture
tunnel-server listens directly on port 443 and peeks at each TLS ClientHello SNI before terminating TLS:
Development Machine / Sandbox
└─ tunnel daemon ──── one outbound WSS (Yamux) ────┐
▼
Visitor (HTTPS / WebRTC) ──▶ :443 SNI Peek ──▶ tunnel-server (single Rust binary)
│ ├─ turn.<host> ──▶ Built-in STUN/TURN Relay
│ ├─ <ui_host> ──▶ Embedded Leptos Web UI + /ui/api/*
│ ├─ <api_host> ──▶ Axum /v1 REST API + /v1/connect
│ ├─ <zone> ──▶ Sign-in gate (/__access/*, /__login)
│ └─ {port}-{id}.<zone> ──▶ Gate check ──▶ Yamux stream
▼
SQLite DB + certs/ + Prometheus (127.0.0.1:9464)
Everything—TLS termination, ACME DNS-01 issuance/renewal, the Yamux control plane, the access-gated reverse proxy, the /v1 OpenAPI management server, the embedded web UI, SQLite persistence, and the STUN/TURN relay—ships in one static binary.
Prerequisites
Server VPS
- Supported Linux distributions: Debian 12+, Ubuntu 22.04+, Fedora 40+, or RHEL/Alma/Rocky 9+.
- Packages:
ca-certificatesandcurl(ACME uses the system CA store even with the static musl server binary).sudo apt-get update && sudo apt-get install -y ca-certificates curl - Inbound firewall ports (both host firewall and cloud security group):
- TCP 80 (HTTP → HTTPS redirect) and TCP 443 (HTTPS, WSS control plane, and TURN-over-TLS).
- Optional WebRTC: UDP/TCP 3478 (STUN/TURN) and UDP 49160–49999 (default media relay range).
- DNS provider API token (unless using
--skip-dns+--own-certificate true):- Cloudflare: Must have both Zone → DNS → Edit AND Zone → Zone → Read for the selected zone. The plain “Edit zone DNS” template lacks Zone Read, which
setupneeds forGET /zones. - Hetzner, DigitalOcean, or AWS Route53 are also supported natively.
- Cloudflare: Must have both Zone → DNS → Edit AND Zone → Zone → Read for the selected zone. The plain “Edit zone DNS” template lacks Zone Read, which
Client Machines and Source Builds
- Client OS: Linux (
x86_64,aarch64) or macOS (aarch64,x86_64). Non-Unix targets are unsupported. - Building from source: Rust 1.89+ and a C toolchain (needed for
ringand bundled SQLite).
Quick Start
Option A: Prebuilt Release Installer (once v1.0.0 is published)
On the VPS, run the server installer (it downloads tunnel-server-<target>, verifies sha256.sum, installs to /usr/local/bin, and runs tunnel-server setup):
# As root, or with sudo for a system install (append `-s -- --staging` for Let's Encrypt staging):
curl -fsSL https://github.com/FlyCockpit/tunnel/releases/latest/download/install.sh | sudo sh
You can verify downloaded release artifacts against SLSA build provenance with:
sha256sum --ignore-missing -c sha256.sum
gh attestation verify tunnel-server-x86_64-unknown-linux-musl --repo FlyCockpit/tunnel
On client machines (Linux or macOS), once the server’s web UI is running, install the version-matched client and start browser login in one step:
curl -fsSL https://tunnel-ui.example.com/install.sh | sh
Homebrew users can also install the client via brew install flycockpit/tap/tunnel.
Option B: Build from Source
# Build the server (omit `--features ui` if you do not need the embedded web UI)
cargo build --release -p tunnel-server
# Build the client (optionally bake in your default server; TUNNEL_SERVER overrides at runtime)
TUNNEL_DEFAULT_SERVER=wss://tunnel.example.com cargo build --release -p tunnel-client
To embed the Leptos web UI (crates/web, built for wasm32-unknown-unknown):
rustup target add wasm32-unknown-unknown
WASM_BINDGEN=/path/to/wasm-bindgen WASM_OPT=/path/to/wasm-opt crates/web/build.sh
cargo build --release -p tunnel-server --features ui
Run Server Setup
# System install (with sudo) or rootless install (without sudo)
sudo tunnel-server setup
The wizard prompts for your hostname, ACME email, DNS provider and token, multi-user preview domain (if needed), WebRTC, and optional SMTP, then writes config.toml, creates and verifies DNS records, issues the wildcard certificate via DNS-01, configures the firewall and systemd service, runs an HTTPS self-test, prints the admin token once, and prints the one-time owner account setup link (if the web UI is enabled).
Enroll a Machine and Share Your First Port
1. Log in from your laptop or workstation
With the web UI enabled, use browser-approved device login (RFC 8628):
tunnel login https://tunnel-ui.example.com
tunnel prints a short code and opens https://tunnel-ui.example.com/device. Sign in, type the code, review the machine name and IP, and approve it.
For headless machines (or when the web UI is off), mint a 15-minute one-time login code on the server first:
# On the server:
sudo tunnel-server client add laptop
# On the laptop (paste the printed tnenr_...@tunnel.example.com code):
tunnel login
2. Share a local port
Start your local dev server (for example on port 3000), then run:
tunnel share 3000 --name "Checkout redesign"
By default, tunnel share creates a link-only tunnel (8-hour lifetime) and prints a single-use access link valid for 10 minutes. Opening that link sets a cookie gate session covering every port on the tunnel.
# Share for a fixed duration and automatically delete on exit or Ctrl-C
tunnel share 3000 --for=30m
# Mint another single-use link (or a reusable link) for a teammate
tunnel link --label bob
tunnel link --reusable --ttl 1h
# Stop sharing and delete the tunnel
tunnel unshare
Known Limitations
- Unix-only client:
tunnelsupports Linux and macOS only (Windows builds fail at compile time). - One daemon per state directory: Each
tunnelstate directory ($XDG_RUNTIME_DIR/tunnelby default) supervises one daemon and one active tunnel. Running a newtunnel share --fororexposewith a different token takes over that daemon; checktunnel status --jsonfirst or pass--state-dirfor isolated tunnels. - Single-instance server: Only one
tunnel-serverprocess may serve a given data directory at a time (serve.lock). - No open signup, SSO, or HTTP Basic: Accounts are created strictly via admin/owner invite links; password-protected previews use the zone-host HTML sign-in form (
/__login), never HTTP Basic authentication. - Single-domain isolation: Hosting the web UI and previews on the same registrable domain is strictly for single-user deployments. Multi-user servers must put
preview_zoneon a separate registrable domain (and public multi-tenant deployments should list the preview zone on the Public Suffix List).