gosuda/portal-tunnel

Publishes localhost services to the agentic web through self-hostable, trustless relays.

Portal is an open-source tool that lets you expose a service running on your own computer (like a web app, API, or game server) to the internet through a relay — a server that forwards traffic to you. Normally you'd need to configure your router (port forwarding), open firewall ports, or set up DNS. Portal removes all of that: you run one command, and you get a public HTTPS URL that points to your local service.

The core idea

You run a small program called a tunnel on your machine. It connects out to a relay server (either one you host yourself or a public one). When someone visits your public URL, the relay forwards the encrypted traffic to your tunnel, which passes it to your local service. Because the tunnel makes an outbound connection, you don't need any inbound firewall rules or port forwarding.

Key features

  • Self-hostable: You can run your own relay with a single Docker command. The whole project is MIT-licensed, with no telemetry, no paid tiers, and no "phone home" behavior.
  • No accounts or API keys: Instead of signing up for a service, Portal uses a local cryptographic identity (a file called identity.json). Authentication happens via challenge-signing, not credentials.
  • End-to-end encryption: For uncached HTTPS traffic, the TLS handshake completes on your machine, not on the relay. The relay only sees encrypted ciphertext — it can't read your traffic. (The relay does sign handshake transcripts for domain verification, but never receives session keys.)
  • MITM detection: Portal can self-probe a sampled connection to check whether a relay is tampering with TLS keying material. The --ban-mitm flag blocks a relay that fails this check.
  • Multi-relay failover: You can combine self-hosted and community relays into a pool, so if one relay goes down, traffic routes through another.
  • Overlay networking: An optional mode (--overlay) routes traffic over an IVNP overlay network for extra routing privacy.
  • Micropayments: Native support for x402 payments — route-level micropayments using Sui USDC, Casper wCSPR, or Nano XNO, without traditional payment processors.

How encryption works (simplified)

  1. A browser connects to the relay, which reads only the TLS handshake's SNI field (the domain name) to figure out which tunnel should receive the traffic.
  2. The relay forwards the raw encrypted stream to your tunnel — it never decrypts it.
  3. Your tunnel completes the TLS handshake locally, deriving session keys on your machine.
  4. The relay continues forwarding ciphertext, but never sees plaintext.

Caveat: Portal reduces relay trust but doesn't eliminate it. A malicious relay holding the certificate's private key could still impersonate an endpoint, and the MITM self-probe only checks sampled connections.

Quick start

Install and expose a local service on port 3000:

curl -fsSL https://github.com/gosuda/portal-tunnel/releases/latest/download/install.sh | bash
portal expose 3000

Portal prints a public HTTPS URL when ready. Common variations:

  • --name myapp — get a short URL like https://myapp.<relay-domain>/ instead of a long identity-bound URL (which includes an Ethereum address).
  • --http-route /api=http://127.0.0.1:3001 --http-route /=http://127.0.0.1:5173 — mount multiple local services behind one domain.
  • --tcp — expose a raw TCP port (e.g., portal expose localhost:25565 --name minecraft --tcp for a Minecraft server).
  • --overlay — prefer an IVNP overlay backhaul path.

Other components

  • AI agent plugins: Two plugins for Codex, Claude Code, and Cursor — portal-tunnel (for exposing and reaching services) and portal-relay (for running a relay). Install via gh skill install or npx skills add.
  • Portal Agent: A daemon for running tunnels persistently in the background or as a system service (portal agent run --config config.toml, plus an interactive dashboard).
  • Public relay registry: Portal ships with a default registry of public relays. If you run your own public relay, you can add it via a pull request to registry.json.

Running your own relay

git clone https://github.com/gosuda/portal-tunnel
cd portal-tunnel && cp .env.example .env
docker compose up

Comparison to alternatives

The README compares Portal to ngrok, Cloudflare Tunnel, and frp. Portal's differentiators: it's fully open source (MIT), self-hostable, requires no account, supports end-to-end tenant TLS, has built-in MITM detection, multi-relay failover, and native x402 payments — features the alternatives lack.

License

MIT License.

Related

  • Project
  • Project
  • Project
  • Project
  • Project