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 +48 -149
- package/dist/cli.js +5304 -0
- package/package.json +57 -48
- package/release/fbi-proxy-linux-arm64 +0 -0
- package/release/fbi-proxy-linux-x64 +0 -0
- package/release/fbi-proxy-macos-arm64 +0 -0
- package/release/fbi-proxy-macos-x64 +0 -0
- package/release/fbi-proxy-windows-arm64.exe +0 -0
- package/release/fbi-proxy-windows-x64.exe +0 -0
- package/rs/fbi-proxy.rs +461 -0
- package/ts/buildFbiProxy.ts +11 -5
- package/ts/cli.ts +53 -49
- package/ts/{dRun.ts → dSpawn.ts} +9 -8
- package/ts/downloadCaddy.ts +15 -22
- package/ts/getProxyFilename.ts +1 -1
package/README.md
CHANGED
|
@@ -1,184 +1,83 @@
|
|
|
1
1
|
# fbi-proxy
|
|
2
2
|
|
|
3
|
-
FBI
|
|
3
|
+
FBI-Proxy provides easy HTTPS access to your local services with intelligent domain routing.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Routing Examples
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
#
|
|
9
|
-
|
|
8
|
+
# Port forwarding
|
|
9
|
+
https://3000.fbi.com → localhost:3000
|
|
10
|
+
https://8080.fbi.com → localhost:8080
|
|
10
11
|
|
|
11
|
-
#
|
|
12
|
-
|
|
12
|
+
# Host--Port forwarding
|
|
13
|
+
https://api--3001.fbi.com → api:3001
|
|
14
|
+
https://db--5432.fbi.com → db:5432
|
|
13
15
|
|
|
14
|
-
#
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
+
WebSocket connections are supported for all patterns.
|
|
40
25
|
|
|
41
|
-
|
|
26
|
+
## Usage
|
|
42
27
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
28
|
+
```sh
|
|
29
|
+
# launch
|
|
30
|
+
bunx fbi-proxy
|
|
46
31
|
|
|
47
|
-
|
|
32
|
+
# expose to LAN
|
|
33
|
+
bunx fbi-proxy --host 0.0.0.0 --port=2432
|
|
48
34
|
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
+
## Development
|
|
56
43
|
|
|
57
44
|
```bash
|
|
58
|
-
#
|
|
45
|
+
# Install dependencies
|
|
59
46
|
bun install
|
|
60
47
|
|
|
61
|
-
#
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
55
|
+
### Prerequisites
|
|
157
56
|
|
|
158
|
-
|
|
57
|
+
- **Bun**: https://bun.sh/
|
|
58
|
+
- **Rust**: https://rustup.rs/
|
|
59
|
+
- **Caddy**: Auto-downloaded if not found
|
|
159
60
|
|
|
160
|
-
|
|
61
|
+
### Configuration
|
|
161
62
|
|
|
162
|
-
|
|
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
|
-
|
|
65
|
+
FBI-Proxy supports the following environment variables for configuration:
|
|
168
66
|
|
|
169
|
-
|
|
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
|
-
-
|
|
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
|
-
|
|
76
|
+
#### CLI Options
|
|
177
77
|
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
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
|
|