Skip to content

Commit 874a407

Browse files
ammarioclaude
andcommitted
feat: default to ports 8080/8443 in server mode
- Server mode now defaults to standard proxy ports (8080 for HTTP, 8443 for HTTPS) - Avoids random port selection, making it easier to configure applications - Custom ports still available via HTTPJAIL_HTTP_BIND and HTTPJAIL_HTTPS_BIND - Updated documentation to reflect the new defaults 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c58cd00 commit 874a407

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ httpjail --config rules.txt -- python script.py
4646

4747
# Run as standalone proxy server (no command execution)
4848
httpjail --server -r "allow: .*"
49-
# Proxy auto-selects available ports (shown in output)
50-
# Configure your application with the displayed ports, e.g.:
51-
# HTTP_PROXY=http://localhost:8852 HTTPS_PROXY=http://localhost:8160
49+
# Server defaults to ports 8080 (HTTP) and 8443 (HTTPS)
50+
# Configure your application:
51+
# HTTP_PROXY=http://localhost:8080 HTTPS_PROXY=http://localhost:8443
5252
```
5353

5454
## Architecture Overview
@@ -180,7 +180,7 @@ httpjail -vvv -r "allow: .*" -- curl https://example.com
180180

181181
# Server mode - run as standalone proxy without executing commands
182182
httpjail --server -r "allow: github\.com" -r "deny: .*"
183-
# Proxy auto-selects available ports in 8000-8999 range (shown in output)
183+
# Server defaults to ports 8080 (HTTP) and 8443 (HTTPS)
184184

185185
# Server mode with custom ports
186186
HTTPJAIL_HTTP_BIND=3128 HTTPJAIL_HTTPS_BIND=3129 httpjail --server -r "allow: .*"
@@ -193,17 +193,17 @@ HTTPJAIL_HTTP_BIND=3128 HTTPJAIL_HTTPS_BIND=3129 httpjail --server -r "allow: .*
193193
httpjail can run as a standalone proxy server without executing any commands. This is useful when you want to proxy multiple applications through the same httpjail instance.
194194

195195
```bash
196-
# Start server with automatic port selection (8000-8999 range)
196+
# Start server with default ports (8080 for HTTP, 8443 for HTTPS)
197197
httpjail --server -r "allow: github\.com" -r "deny: .*"
198-
# Output: Server running on ports 8852 (HTTP) and 8160 (HTTPS). Press Ctrl+C to stop.
198+
# Output: Server running on ports 8080 (HTTP) and 8443 (HTTPS). Press Ctrl+C to stop.
199199

200-
# Start server with specific ports using environment variables
200+
# Start server with custom ports using environment variables
201201
HTTPJAIL_HTTP_BIND=3128 HTTPJAIL_HTTPS_BIND=3129 httpjail --server -r "allow: .*"
202202
# Output: Server running on ports 3128 (HTTP) and 3129 (HTTPS). Press Ctrl+C to stop.
203203

204204
# Configure your applications to use the proxy:
205-
export HTTP_PROXY=http://localhost:8852
206-
export HTTPS_PROXY=http://localhost:8160
205+
export HTTP_PROXY=http://localhost:8080
206+
export HTTPS_PROXY=http://localhost:8443
207207
curl https://github.com # This request will go through httpjail
208208
```
209209

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,16 @@ async fn main() -> Result<()> {
325325
let rule_engine = RuleEngine::new(rules, args.dry_run, args.log_only);
326326

327327
// Get ports from env vars (optional)
328+
// In server mode, default to 8080/8443 if not specified
328329
let http_port = std::env::var("HTTPJAIL_HTTP_BIND")
329330
.ok()
330-
.and_then(|s| s.parse::<u16>().ok());
331+
.and_then(|s| s.parse::<u16>().ok())
332+
.or_else(|| if args.server { Some(8080) } else { None });
331333

332334
let https_port = std::env::var("HTTPJAIL_HTTPS_BIND")
333335
.ok()
334-
.and_then(|s| s.parse::<u16>().ok());
336+
.and_then(|s| s.parse::<u16>().ok())
337+
.or_else(|| if args.server { Some(8443) } else { None });
335338

336339
// Determine bind address based on platform and mode
337340
let bind_address = if args.weak {

0 commit comments

Comments
 (0)