fbi-proxy 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,184 +1,83 @@
1
1
  # fbi-proxy
2
2
 
3
- FBI Proxy is a super easy way to turn your local network over HTTPS with intelligent domain routing.
3
+ FBI-Proxy provides easy HTTPS access to your local services with intelligent domain routing.
4
4
 
5
- ## Quick Start
5
+ ## Routing Examples
6
6
 
7
7
  ```bash
8
- # Install dependencies
9
- bun install
8
+ # Port forwarding
9
+ https://3000.fbi.com → localhost:3000
10
+ https://8080.fbi.com → localhost:8080
10
11
 
11
- # Build and start the proxy system
12
- bun run start
12
+ # Host--Port forwarding
13
+ https://api--3001.fbi.com → api:3001
14
+ https://db--5432.fbi.com → db:5432
13
15
 
14
- # Development mode with auto-reload
15
- bun run dev
16
- ```
16
+ # Subdomain routing (with Host header)
17
+ https://admin.app.fbi.com → app:80 (Host: admin)
18
+ https://v2.api.fbi.com → api:80 (Host: v2)
17
19
 
18
- ## Build Scripts
19
-
20
- ### Available Commands:
21
-
22
- ```bash
23
- # Build TypeScript CLI
24
- bun run build:ts
25
-
26
- # Build Rust proxy binary
27
- bun run build:rs
28
-
29
- # Full build (both TypeScript and Rust)
30
- bun run build
31
-
32
- # Development with hot reload
33
- bun run dev
34
-
35
- # Production start
36
- bun run start
20
+ # Direct host forwarding
21
+ https://myserver.fbi.com → myserver:80
37
22
  ```
38
23
 
39
- ## Architecture
24
+ WebSocket connections are supported for all patterns.
40
25
 
41
- The FBI Proxy consists of three main components:
26
+ ## Usage
42
27
 
43
- - **TypeScript CLI** (`ts/cli.ts`): Orchestrates the entire system, manages Caddy and Rust proxy processes
44
- - **Rust Proxy Server** (`proxy.rs`): High-performance HTTP/WebSocket proxy using Hyper framework
45
- - **Caddy Server**: Handles TLS termination, SSL certificates, and domain routing
28
+ ```sh
29
+ # launch
30
+ bunx fbi-proxy
46
31
 
47
- ### How It Works
32
+ # expose to LAN
33
+ bunx fbi-proxy --host 0.0.0.0 --port=2432
48
34
 
49
- 1. **CLI** downloads/manages Caddy binary and builds the Rust proxy
50
- 2. **Caddy** receives incoming HTTPS requests and forwards them to the Rust proxy
51
- 3. **Rust Proxy** intelligently routes requests based on hostname patterns
35
+ # with caddy, forwarding *.fbi.com
36
+ bunx fbi-proxy --caddy=fbi.com
52
37
 
53
- ## Development Workflow
38
+ # run with docker, forwarding *.your-domain.com to host.
39
+ docker run --rm --name fbi-proxy --network=host -v caddy_data:/etc/caddy/data snomiao/fbi-proxy --reverse-proxy=your-domain.com
40
+ ```
54
41
 
55
- ### First Time Setup:
42
+ ## Development
56
43
 
57
44
  ```bash
58
- # 1. Install dependencies (requires Bun)
45
+ # Install dependencies
59
46
  bun install
60
47
 
61
- # 2. Start development (automatically builds and runs)
48
+ # Start development
62
49
  bun run dev
63
- ```
64
-
65
- ### Daily Development:
66
-
67
- ```bash
68
- # Development with hot reload for both Caddy and Rust
69
- bun run dev
70
-
71
- # Or run individual components:
72
- bun run dev:caddy # Start Caddy with file watching
73
- bun run dev:rs # Start Rust proxy with bacon (auto-rebuild)
74
- ```
75
-
76
- ### Production Deployment:
77
-
78
- ```bash
79
- bun run build # Build optimized binaries
80
- bun run start # Start production services
81
- ```
82
-
83
- ## Prerequisites
84
50
 
85
- - **Bun**: JavaScript runtime and package manager (install from https://bun.sh/)
86
- - **Rust**: For building the proxy binary (install from https://rustup.rs/)
87
- - **Caddy**: Automatically downloaded by the CLI if not found
88
-
89
- ## Routing Features
90
-
91
- The FBI Proxy supports intelligent hostname-based routing with the following patterns:
92
-
93
- ### 1. Port Forwarding
94
-
95
- - `https://3000.fbi.com` → `http://localhost:3000`
96
- - `https://8080.fbi.com` → `http://localhost:8080`
97
-
98
- ### 2. Host--Port Forwarding
99
-
100
- - `https://localhost--3000.fbi.com` → `http://localhost:3000`
101
- - `https://myserver--8080.fbi.com` → `http://myserver:8080`
102
-
103
- ### 3. Subdomain Hoisting
104
-
105
- - `https://api.myserver.fbi.com` → `http://myserver:80` (with Host: `api`)
106
- - `https://admin.localhost.fbi.com` → `http://localhost:80` (with Host: `admin`)
107
-
108
- ### 4. Direct Host Forwarding
109
-
110
- - `https://myserver.fbi.com` → `http://myserver:80`
111
- - `https://localhost.fbi.com` → `http://localhost:80`
112
-
113
- ### WebSocket Support
114
-
115
- All routing patterns support WebSocket connections with automatic upgrade handling.
116
-
117
- ## Configuration
118
-
119
- ### Environment Variables
120
-
121
- ```env
122
- FBIHOST="fbi.com" # Default domain (configurable via --fbihost)
123
- FBIPROXY_PORT="24306" # Internal proxy port (auto-assigned)
124
- ```
125
-
126
- ### CLI Options
127
-
128
- ```bash
129
- bun run ts/cli.ts --help
130
-
131
- Options:
132
- --help Show help message
133
- --fbihost Set the FBI host (default: fbi.com)
134
- ```
135
-
136
- ## Service Configuration Examples
137
-
138
- Create custom service mappings by modifying the routing logic or using the built-in patterns:
139
-
140
- ```bash
141
- # Direct port access
142
- https://3000.fbi.com # → localhost:3000
143
- https://5173.fbi.com # → localhost:5173 (Vite dev server)
144
- https://8000.fbi.com # → localhost:8000 (VS Code server)
145
-
146
- # Named services with custom ports
147
- https://api--3001.fbi.com # → api:3001
148
- https://db--5432.fbi.com # → db:5432
149
-
150
- # Subdomain routing
151
- # Subdomain routing
152
- https://admin.app.fbi.com # → app:80 with Host: admin
153
- https://v2.api.fbi.com # → api:80 with Host: v2
51
+ # Or production
52
+ bun run build && bun run start
154
53
  ```
155
54
 
156
- ## Technical Details
55
+ ### Prerequisites
157
56
 
158
- ### Rust Proxy Implementation (`proxy.rs`)
57
+ - **Bun**: https://bun.sh/
58
+ - **Rust**: https://rustup.rs/
59
+ - **Caddy**: Auto-downloaded if not found
159
60
 
160
- The Rust proxy server implements the following routing logic:
61
+ ### Configuration
161
62
 
162
- 1. **Number Host Detection**: Pure numeric hosts (e.g., `3000`) route to `localhost:3000`
163
- 2. **Double-Dash Parsing**: `host--port` format routes to `host:port`
164
- 3. **Subdomain Hoisting**: Multi-level domains route to the root domain with subdomain as Host header
165
- 4. **Default Port 80**: Simple hostnames default to port 80
63
+ #### Environment Variables
166
64
 
167
- ### TypeScript CLI (`ts/cli.ts`)
65
+ FBI-Proxy supports the following environment variables for configuration:
168
66
 
169
- The CLI manages:
67
+ | Variable | Description | Default |
68
+ |----------|-------------|---------|
69
+ | `FBI_PROXY_PORT` | Port for the proxy server to listen on | `2432` |
70
+ | `FBI_PROXY_HOST` | Host/IP address to bind to | `127.0.0.1` |
71
+ | `RUST_LOG` | Log level for the Rust proxy (error, warn, info, debug, trace) | `info` |
72
+ | `FBIPROXY_PORT` | Internal proxy port (auto-assigned) | Auto |
170
73
 
171
- - Binary discovery and building (Rust proxy, Caddy download)
172
- - Process orchestration with proper signal handling
173
- - Port management and environment variable passing
174
- - Hot reloading during development
74
+ Command-line arguments take precedence over environment variables.
175
75
 
176
- ### Caddy Configuration (`Caddyfile`)
76
+ #### CLI Options
177
77
 
178
- - Automatic HTTPS with on-demand TLS certificates
179
- - Regex-based host header matching
180
- - Reverse proxy configuration with header manipulation
181
- - Support for wildcard subdomain routing
78
+ - Default domain: `fbi.com` (change with `--fbihost`)
79
+ - Host binding: `--host` or `FBI_PROXY_HOST` env var
80
+ - Port binding: `--port` or `FBI_PROXY_PORT` env var
182
81
 
183
82
  ## License
184
83