Awesome Go

expose

CategoryNetworking
SubcategoryNetworking
Stars27

Lightweight, open-source secure tunneling tool to expose local servers to the internet

About expose

Expose โ€“ Pure Go Localhost Tunneling CLI

Expose Terminal Demo

Downloads Documentation Tests codecov License: Apache 2.0 Expose CLI | AlternativeTo

The drop-in, open-source Go alternative to ngrok.
Start instantly on free public relays with zero config and zero signups, or graduate to your own self-hosted relay on a $5 VPS in a single <10MB binary. Zero lock-in.

Install via Homebrew:

brew install kernelshard/tap/expose

Tunnel your local server (e.g. port 3000):

expose tunnel 3000

๐Ÿ’ก What is this for?

When you run an app on http://localhost:3000, only your laptop can access it. Expose creates a temporary public HTTPS URL that connects directly to your local server:

  • ๐Ÿช Webhook Testing: Give Stripe, GitHub, or Twilio a live HTTPS URL to test webhook callbacks locally.
  • ๐Ÿ“ฑ Mobile & Device Testing: Open your local website on a physical smartphone or tablet over 4G/5G.
  • ๐Ÿ‘ฅ Instant Previews: Send a live demo link to a friend or client without deploying to cloud servers.
  • ๐Ÿ  Private Self-Hosting: Route traffic through your own private VPS instead of commercial SaaS relays.

๐Ÿ†š Why Expose?

Feature๐Ÿš€ ExposengrokCloudflare TunnelLocalTunnel (Node)
Zero Signup Requiredโœ… InstantโŒ Mandatory accountโŒ Mandatory accountโœ… Instant
Single Static Binaryโœ… (<10MB)โœ… (~30MB)โœ… (~50MB)โŒ (requires Node.js)
Open Sourceโœ… Apache 2.0โŒ Proprietaryโœ… Apache 2.0โœ… MIT
Self-Hostable Relayโœ… expose serverโŒ SaaS onlyโŒ Cloudflare networkโš ๏ธ Legacy Node server
Language & RuntimePure Go (zero CGO)Go / CGo daemonNode.js (V8 heap)
Free Custom Domains๐ŸŸก Partial (Self-Hosted)๐Ÿ’ฒ Paid planโœ… Cloudflare DNSโŒ Not supported
Memorable Subdomainsโœ… Auto-assigned (swift-falcon-4821)โŒ Random hex (free tier)โŒ Random hexโš ๏ธ Limited words

โšก Quickstart

Option A: Instant Public Tunnel (Zero Setup)

Expose your local development server in seconds without creating an account:

# Public relay (default: localhost.run)
expose tunnel 3000

# Or via Cloudflare Quick Tunnels
expose tunnel 3000 --provider=cloudflare

# Or via LocalTunnel
expose tunnel 3000 --provider=localtunnel

Option B: Sovereign Mode (Self-Hosted on Your VPS)

Want permanent custom subdomains, full privacy, and zero rate limits? Run your private relay on any $5 VPS:

# 1. On your VPS (Turnkey Docker + Caddy Auto-TLS)
git clone https://github.com/kernelshard/expose.git && cd expose/deploy
cp .env.example .env && docker compose up -d

# 2. On your laptop
expose tunnel 3000 --server=tunnel.yourdomain.com:7890 --subdomain=api

๐Ÿ“ฆ Installation Options

1. Homebrew (macOS & Linux โ€” Recommended)

brew install kernelshard/tap/expose

2. One-Line Shell Installer

curl -fsSL https://raw.githubusercontent.com/kernelshard/expose/main/install.sh | sh

Pin a specific version or install to a custom path:

# Pin version
VERSION=v0.6.6 curl -fsSL https://raw.githubusercontent.com/kernelshard/expose/main/install.sh | sh

# Custom directory
BINDIR=~/.local/bin curl -fsSL https://raw.githubusercontent.com/kernelshard/expose/main/install.sh | sh

3. Pre-built Binaries

Download the latest pre-compiled binary for your architecture (macOS, Linux, Windows) from the Releases Page.

4. Via Go Install (Go 1.22+)

go install github.com/kernelshard/expose/cmd/expose@latest

5. From Source

git clone https://github.com/kernelshard/expose.git
cd expose
go build -o expose ./cmd/expose
./expose --version

๐Ÿ  Self-Hosted Relay Server

Need complete privacy, permanent custom subdomains, and zero third-party relay dependence? Run your own private tunnel gateway on any $5 VPS (DigitalOcean, Hetzner, AWS Lightsail).

Option 1: Turnkey Docker Compose + Caddy Auto-TLS (Recommended)

The fastest path to production with automated TLS termination and edge reverse-proxying:

git clone https://github.com/kernelshard/expose.git
cd expose/deploy
cp .env.example .env
# Set DOMAIN=tunnel.yourdomain.com in .env
docker compose up -d

See deploy/README.md for DNS setup and configuration options.

Option 2: Standalone Binary

Run the native compiled binary directly on bare metal:

# Start your private relay server (open by default)
expose server --domain=tunnel.mysite.com --control-port=7890 --public-port=8080

# Or protect with an auth token (recommended for public VPS)
expose server --domain=tunnel.mysite.com --token=mysecret

Connect From Your Laptop

# Standard connection
expose tunnel 3000 --server=tunnel.mysite.com:7890 --subdomain=my-app

# If your server requires an auth token
expose tunnel 3000 --server=tunnel.mysite.com:7890 --token=mysecret

โš™๏ธ Project Configuration (.expose.yml)

Save defaults per project so you can just type expose tunnel:

# Create .expose.yml in current directory
$ expose init
โœ“ Config created: .expose.yml
project: expose
port: 3000

Manage and query configuration values:

expose config list
expose config get port

๐Ÿ— Architecture & Systems Design

expose/
โ”œโ”€โ”€ cmd/expose/       # CLI entry point (Cobra)
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ cli/          # Cobra subcommands & flag parsing
โ”‚   โ”œโ”€โ”€ config/       # YAML config management
โ”‚   โ”œโ”€โ”€ pool/         # sync.Pool 32KB buffer recycling (0 allocs/op)
โ”‚   โ”œโ”€โ”€ provider/     # Tunnel backends (Localhost.run, Cloudflare, Self-Hosted, LocalTunnel)
โ”‚   โ”œโ”€โ”€ server/       # Self-hosted relay control plane & TCP proxy
โ”‚   โ”œโ”€โ”€ tunnel/       # Core service orchestration & connection lifecycle
โ”‚   โ””โ”€โ”€ version/      # Build metadata & version injection
โ””โ”€โ”€ .expose.yml       # Local project configuration

Data Plane & Socket Topology

[ Public Visitor ]
       โ”‚ 1. Connects to https://demo.tunnel.com
       โ–ผ
[ Expose Relay Server (VPS) ]
  โ”œโ”€โ”€ 2. Fast L7 Peek: Read initial bytes to extract `Host:` header
  โ””โ”€โ”€ 3. Drop to Layer 4: Spliced directly to standby client data socket
       โ”‚
       โ”‚ (Bidirectional raw TCP stream via sync.Pool 32KB buffers)
       โ–ผ
[ Expose Client (Laptop) ]
  โ””โ”€โ”€ 4. Forward raw byte stream to http://localhost:3000

Key Systems Design Principles

  • Layer 4 Raw Socket Splicing: Rather than incurring full HTTP/2 or JSON parsing overhead on every packet, Expose inspects only the initial bytes to extract the Host: header for subdomain routing. Once matched, it immediately drops down to raw bidirectional Layer 4 TCP streaming (io.CopyBuffer).
  • Zero-Allocation Buffer Recycling (sync.Pool): Recycles 32KB copy buffers using slice pointers (*[]byte) to eliminate Go interface boxing allocations on the heap.
  • Bounded Concurrency Brakes: The relay server advertises connection limits (MaxConnections) during handshake; the client bounds worker goroutines and runs proxy forwarding synchronously to prevent 100% CPU dial spin-loops.
  • Graceful Socket Teardown: Coordinates bidirectional stream termination, guaranteeing both reader and writer sockets close cleanly on io.EOF without leaking goroutines or file descriptors.
  • Modular Provider Abstraction: Decoupled Provider interface cleanly isolates CLI and service lifecycles from underlying network transports (LocalTunnel, Cloudflare, and Self-Hosted relays).

Performance Benchmarks (sync.Pool vs. Naive Buffers)

Bidirectional network proxying performance on the self-hosted relay gateway:

ImplementationMemory AllocationsHeap Churn (B/op)Throughput Delta
Standard Unpooled BuffersHigh GC Pressure~34,209 B/opBaseline
Expose 32KB sync.Pool0 allocs during stream1,444 B/op (-95.8%)+26% Throughput

Reproduce benchmark locally:

go test -bench=BenchmarkCopy ./internal/pool -benchmem

๐Ÿงช Development & Testing

# Run all unit tests with Go race detector
go test ./... -v -race -cover

# Package-specific coverage
go test ./internal/tunnel -cover
go test ./internal/server -cover
go test ./internal/provider -cover

๐Ÿค Contributing

Contributions are welcome! Please check out CONTRIBUTING.md for branch strategy, test requirements, and code style guidelines.


๐Ÿ“ License

Distributed under the Apache License 2.0. See LICENSE for details.


Made with โค๏ธ by @kernelshard

Frequently Asked Questions

What is expose?

expose is a Networking library for the Go programming language. Lightweight, open-source secure tunneling tool to expose local servers to the internet

How do I install expose?

Install expose with the Go module system using `go get kernelshard/expose`. Check the repository for the current installation instructions.

What category does expose belong to?

expose is listed under Networking, specifically Networking.

โ† Back to Networking