Sign in

Bridge Service

WebSocket tunneling service for connecting cloud-deployed Cosmos to on-premises systems behind VPNs and firewalls

bridge
bridgetunnelwebsocketon-premisesvpnproxy

Updated 2026-11-03

Verified 2026-11-03

Repository: cosmos-bridge Language: Go Port: 8109 (server) Registry: in-memory, rebuilt by client reconnects

Overview

The Bridge is a generic HTTP tunnel that enables cloud-deployed Cosmos services to communicate with on-premises systems behind VPNs and firewalls. It consists of two components:

  • Server (cmd/server) — Deployed on Kubernetes. Accepts WebSocket connections from bridge clients and provides a proxy API for other Cosmos services to route requests through active bridges.
  • Client (cmd/client) — Standalone binary run on the user's VPN-connected machine. Connects to the server via WebSocket, receives HTTP request descriptors, executes them against local/on-prem endpoints, and returns responses.

Architecture

Bridge tunnel flow

Source

Loading diagram...

  1. The client binary runs on a VPN-connected machine and establishes a persistent WebSocket connection to the bridge server.
  2. When a Cosmos service needs to reach an on-prem system, it POSTs to /api/v1/proxy with the target URL and request details.
  3. The bridge server forwards the request descriptor over the WebSocket to the client.
  4. The client executes the HTTP request locally (where it has network access to the on-prem system) and streams the response back.
  5. If the server restarts, active clients reconnect and repopulate the in-memory registry.

Authentication

  • Bridge tokens: Cosmos JWTs are validated through User Service JWKS. The CLI can accept a token explicitly or obtain one through browser OAuth2.
  • JWT validation: Server validates tokens against the User Service JWKS endpoint (/.well-known/jwks.json).
  • Client auth: Client connects to the WebSocket endpoint with ?token=<bridge-token>.
  • OAuth client mode: If no token is provided, the CLI can use browser-based Cosmos OAuth2 based on GET /api/v1/auth/config.

API Endpoints

EndpointMethodDescription
/healthGETLiveness probe
/readyGETReadiness probe
/api/v1/proxyPOSTProxy HTTP request through a bridge
/api/v1/bridgesGETList active bridges
/api/v1/bridges/statusGETCheck if user has active bridge
/api/v1/bridges/{id}DELETEDisconnect a bridge
/api/v1/auth/configGETPublic OAuth2 configuration for bridge CLI
/api/v1/releases/{os}/{arch}GETDownload client binary
/api/v1/releasesGETList available binaries
/ws?token=<jwt>WebSocketBridge client connection

Configuration

Env VariableDefaultDescription
PORT8000Server port
LOG_LEVELinfoServer log level
JWKS_URLShttp://user-web:8000/.well-known/jwks.jsonComma-separated JWKS endpoints for JWT validation
USER_SERVICE_URLhttp://user-web:8000User Service URL. When unset, the server uses the USER_SERVICE_URLS entry for DEFAULT_ENVIRONMENT.
USER_SERVICE_URLS—Per-environment User Service URLs: develop=http://...,uat=http://...
DEFAULT_ENVIRONMENTuatEnvironment used to pick defaults from the per-environment maps
DEFAULT_ORG_ID—Default organization ID. When unset, the server uses the DEFAULT_ORG_IDS entry for DEFAULT_ENVIRONMENT.
DEFAULT_ORG_IDS—Per-environment default organization IDs: develop=<org-id>,uat=<org-id>
PROXY_TIMEOUT30Proxy request timeout in seconds
HEARTBEAT_INTERVAL30WebSocket heartbeat interval
MAX_REQUEST_BODY_SIZE10485760Max proxied request body size
BINARIES_DIR/binariesDirectory containing client binaries
CORS_ALLOWED_ORIGINS*CORS allowed origins
OAUTH2_AUTH_URL—Default Cosmos OAuth2 base URL for CLI login
OAUTH2_CLIENT_ID—Default OAuth2 client ID for CLI login
OAUTH2_ENVS—Per-environment OAuth2 config: env=url|client_id|bridge_url (bridge URL optional), comma-separated

Client Binary Distribution

Client binaries are cross-compiled for multiple OS/architecture combinations and served directly by the bridge server. Users download the appropriate binary for their platform from the Jumpstart UI or via the API:

Use GET /api/v1/releases to list binaries and GET /api/v1/releases/{os}/{arch} to download the matching client. Older /api/v1/download paths redirect to the releases endpoints.

Supported platforms: darwin/arm64, darwin/amd64, linux/amd64, linux/arm64, windows/amd64.

Client Usage

bash
# macOS (first time — remove quarantine)
chmod +x cosmos-bridge-darwin-arm64
xattr -d com.apple.quarantine cosmos-bridge-darwin-arm64

# Connect to bridge server
./cosmos-bridge-darwin-arm64 --token <bridge-token>

# With custom options
./cosmos-bridge-darwin-arm64 \
  --token <token> \
  --server wss://cosmos.example.com/bridge \
  --insecure \          # Skip TLS for target requests (e.g., self-signed SAP certs)
  --ca-cert /path/to/ca.pem \
  --verbose

Connection Registry

The bridge server keeps active client connections in memory. It stores client ID, user identity, connection time, heartbeat status, and routing metadata for /api/v1/proxy. There is no Redis dependency for bridge connection state; clients reconnect automatically after a server restart.