| Crates.io | logprox |
| lib.rs | logprox |
| version | 0.1.0 |
| created_at | 2025-10-25 15:35:28.535528+00 |
| updated_at | 2025-10-25 15:35:28.535528+00 |
| description | A blazing-fast HTTP proxy with conditional logging and request control |
| homepage | https://github.com/bryan-lott/logprox |
| repository | https://github.com/bryan-lott/logprox |
| max_upload_size | |
| id | 1900357 |
| size | 101,038 |
A blazing-fast HTTP proxy with conditional logging and request control
If LogProx helps your team, consider supporting development:
⚡ Exceptionally low latency • 🔍 Conditional logging • 🛡️ Request filtering • 🔄 Hot reload
Quick Start • Features • Configuration • Examples
# Install from crates.io
cargo install logprox
# Or build from source
git clone https://github.com/bryan-lott/logprox.git
cd logprox
cargo build --release
# Start with default config
./target/release/logprox
# Or specify custom config
./target/release/logprox --config my-config.yaml
# Set environment variables
PORT=8080 CONFIG_FILE=config.yaml ./target/release/logprox
Create a config.yaml:
logging:
default: false
rules:
- name: "Monitor API calls"
match_conditions:
path:
patterns: ["/api/.*"]
capture:
method: true
path: true
timing: true
Start LogProx and make a request:
curl -X GET "http://localhost:3000/api/test"
Accessing an external API with a deprecated version can cause additional cost, bad data, and/or banning of access from the API. Tracking down where those requests are coming from can be a huge headache.
LogProx offers a solution: Place it between any internal callers and the external API, set up rules to log for specific headers, methods, paths, or request bodies.
LogProx sits between your application and upstream APIs, providing transparent proxying with intelligent request processing:
┌─────────────┐ ┌───────────┐ ┌────────────────┐
│ Client │───▶│ LogProx │───▶│ Upstream API │
│ Application │ │ │ │ │
└─────────────┘ └───────────┘ └────────────────┘
│
▼
┌────────────┐
│ Logs & │
│ Metrics │
└────────────┘
Request Flow:
Benchmark Results (on standard hardware):
Performance Philosophy:
We're actively working on these features. Have a suggestion? Open an issue!
LogProx uses YAML configuration files with support for environment variable substitution (${VAR_NAME}).
| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
Server port to listen on |
CONFIG_FILE |
config.yaml |
Path to configuration file |
server:
port: 3000
config_file: config.yaml
logging:
default: false
rules:
- name: "API Monitoring"
match_conditions:
path: { patterns: ["/api/.*"] }
methods: ["POST", "PUT"]
capture: { method: true, path: true, timing: true }
drop:
default: false
rules:
- name: "Block Bots"
match_conditions:
headers: { "user-agent": ".*bot.*" }
response: { status_code: 403, body: "Access denied" }
response_logging:
default: false
rules:
- name: "Log Errors"
match_conditions:
status_codes: [400, 401, 403, 404, 500, 502, 503]
capture: { status_code: true, timing: true }
server:
port: 3000 # Server port (can be overridden by PORT env var)
config_file: config.yaml # Config file path (can be overridden by CONFIG_FILE env var)
logging:
default: false # Default logging behavior if no rules match
rules: # Array of logging rules
- name: "Rule Name" # Descriptive name for the rule
match_conditions: # Conditions that must ALL match
path: # URL path patterns (regex)
patterns:
- "/api/.*"
methods: # HTTP methods to match
- "POST"
- "PUT"
headers: # Required headers and regex patterns
"content-type": "application/json.*"
"authorization": "Bearer .*"
body: # Request body patterns (regex)
patterns:
- '"amount":\s*\d+'
capture: # What to include in logs
headers: # List of header names to capture
- "content-type"
- "user-agent"
body: true # Whether to log request body
method: true # Whether to log HTTP method
path: true # Whether to log URL path
timing: true # Whether to log timing information
drop:
default: false # Default drop behavior if no rules match
rules: # Array of drop rules
- name: "Rule Name" # Descriptive name for the rule
match_conditions: # Conditions that must ALL match (same as logging)
path:
patterns:
- "/deprecated/.*"
methods:
- "GET"
headers:
"user-agent": ".*bot.*"
body:
patterns:
- "<script>.*</script>"
response: # Response to return when dropping
status_code: 403 # HTTP status code
body: "Access denied" # Response body (supports env vars)
response_logging:
default: false # Default logging behavior if no rules match
rules: # Array of response logging rules
- name: "Log error responses" # Descriptive name for the rule
match_conditions: # Conditions that must ALL match
status_codes: # HTTP status codes to match
- 400
- 401
- 403
- 404
- 500
headers: # Required headers and regex patterns
"content-type": "application/json.*"
body: # Response body patterns (regex)
patterns:
- "error.*"
capture: # What to include in logs
headers: # List of header names to capture
- "content-type"
- "x-request-id"
body: true # Whether to log response body
status_code: true # Whether to log HTTP status code
timing: true # Whether to log timing information
All pattern matching uses Rust's regex engine. Common patterns:
.* - Match any characters^/api/ - Match paths starting with /api/\d+ - Match one or more digits(option1|option2) - Match either option1 or option2logging:
default: false
rules:
- name: "Log API requests"
match_conditions:
path:
patterns:
- "/api/.*"
methods:
- "POST"
- "PUT"
- "DELETE"
capture:
headers:
- "content-type"
- "authorization"
body: true
method: true
path: true
timing: true
drop:
default: false
rules:
- name: "Block XSS attempts"
match_conditions:
body:
patterns:
- "<script>.*</script>"
- "javascript:"
- "onload="
response:
status_code: 400
body: "Malicious content detected"
drop:
default: false
rules:
- name: "Block bot traffic"
match_conditions:
headers:
"user-agent": ".*(bot|crawler|spider).*"
response:
status_code: 429
body: "Rate limit exceeded"
response_logging:
default: false
rules:
- name: "Log API errors"
match_conditions:
status_codes:
- 400
- 401
- 403
- 404
- 500
- 502
- 503
capture:
headers:
- "content-type"
- "x-correlation-id"
body: true
status_code: true
timing: true
| Endpoint | Method | Description | Response |
|---|---|---|---|
/health |
GET | Service health check | 200 OK with body "OK" |
/config |
GET | Current configuration | 200 OK with JSON config |
/config/docs |
GET | Configuration documentation | 200 OK with Markdown |
/config/reload |
POST | Reload configuration | 200 OK or 500 Error |
# Health check
curl http://localhost:3000/health
# Get current config
curl http://localhost:3000/config | jq .
# Reload configuration
curl -X POST http://localhost:3000/config/reload
# View documentation
curl http://localhost:3000/config/docs
Configuration Errors:
# Validate your YAML syntax
yamllint config.yaml
# Test with verbose logging
RUST_LOG=debug ./logprox
Performance Issues:
htop or similarConnection Problems:
Enable detailed logging:
RUST_LOG=logprox=debug ./logprox
${VAR_NAME} syntaxWe welcome contributions! See CONTRIBUTING.md for guidelines.
GNU GPLv3 © Bryan Lott
Built with ❤️ in Rust
A fast, reliable, and secure HTTP proxy for modern applications