fbi-proxy-1.3.0 is not a library.
fbi-proxy
FBI Proxy is a super easy way to turn your local network over HTTPS with intelligent domain routing.
Quick Start
# Install dependencies
# Build and start the proxy system
# Development mode with auto-reload
Build Scripts
Available Commands:
# Build TypeScript CLI
# Build Rust proxy binary
# Full build (both TypeScript and Rust)
# Development with hot reload
# Production start
Architecture
The FBI Proxy consists of three main components:
- TypeScript CLI (
ts/cli.ts): Orchestrates the entire system, manages Caddy and Rust proxy processes - Rust Proxy Server (
proxy.rs): High-performance HTTP/WebSocket proxy using Hyper framework - Caddy Server: Handles TLS termination, SSL certificates, and domain routing
How It Works
- CLI downloads/manages Caddy binary and builds the Rust proxy
- Caddy receives incoming HTTPS requests and forwards them to the Rust proxy
- Rust Proxy intelligently routes requests based on hostname patterns
Development Workflow
First Time Setup:
# 1. Install dependencies (requires Bun)
# 2. Start development (automatically builds and runs)
Daily Development:
# Development with hot reload for both Caddy and Rust
# Or run individual components:
Production Deployment:
Prerequisites
- Bun: JavaScript runtime and package manager (install from https://bun.sh/)
- Rust: For building the proxy binary (install from https://rustup.rs/)
- Caddy: Automatically downloaded by the CLI if not found
Routing Features
The FBI Proxy supports intelligent hostname-based routing with the following patterns:
1. Port Forwarding
https://3000.fbi.com→http://localhost:3000https://8080.fbi.com→http://localhost:8080
2. Host--Port Forwarding
https://localhost--3000.fbi.com→http://localhost:3000https://myserver--8080.fbi.com→http://myserver:8080
3. Subdomain Hoisting
https://api.myserver.fbi.com→http://myserver:80(with Host:api)https://admin.localhost.fbi.com→http://localhost:80(with Host:admin)
4. Direct Host Forwarding
https://myserver.fbi.com→http://myserver:80https://localhost.fbi.com→http://localhost:80
WebSocket Support
All routing patterns support WebSocket connections with automatic upgrade handling.
Configuration
Environment Variables
FBIHOST="fbi.com" # Default domain (configurable via --fbihost)
FBIPROXY_PORT="24306" # Internal proxy port (auto-assigned)
CLI Options
)
Service Configuration Examples
Create custom service mappings by modifying the routing logic or using the built-in patterns:
# Direct port access
# Named services with custom ports
# Subdomain routing
# Subdomain routing
Technical Details
Rust Proxy Implementation (proxy.rs)
The Rust proxy server implements the following routing logic:
- Number Host Detection: Pure numeric hosts (e.g.,
3000) route tolocalhost:3000 - Double-Dash Parsing:
host--portformat routes tohost:port - Subdomain Hoisting: Multi-level domains route to the root domain with subdomain as Host header
- Default Port 80: Simple hostnames default to port 80
TypeScript CLI (ts/cli.ts)
The CLI manages:
- Binary discovery and building (Rust proxy, Caddy download)
- Process orchestration with proper signal handling
- Port management and environment variable passing
- Hot reloading during development
Caddy Configuration (Caddyfile)
- Automatic HTTPS with on-demand TLS certificates
- Regex-based host header matching
- Reverse proxy configuration with header manipulation
- Support for wildcard subdomain routing
License
MIT License - see LICENSE file for details