reqwest-proxy-pool
Proxy pool middleware implementation for reqwest-middleware.
Features
✨ Comprehensive Proxy Support
- Automatic parsing of free SOCKS5/SOCKS5H proxies from multiple sources
- Per-host proxy pools with independent health-check policies
⚡ Intelligent Proxy Management
- Multiple proxy selection strategies (FastestResponse, MostReliable, RoundRobin, Random)
- Per-proxy minimum request interval to avoid bans
- Automatic retry mechanism for failed requests
- Retry strategy control (
DefaultSelection/NewProxyOnRetry) - Custom response classifier for business-level proxy health (anti-bot/captcha detection)
🔧 Easy Configuration
- Simple builder pattern for configuration
- Seamless integration with reqwest middleware stack
Quickstart
Installation
Add to your Cargo.toml:
[]
= "0.13"
= "0.3"
= "0.5"
= { = "1", = ["full"] }
Usage
use ClientBuilder;
use ;
use Duration;
;
async
Configuration Options
ProxyPoolConfig:
| Option | Description | Default |
|---|---|---|
sources |
List of URLs providing proxy lists (shared by all host pools) | Required |
hosts |
List of HostConfig (one host = one pool) |
Required |
HostConfig:
| Option | Description | Default |
|---|---|---|
host |
Target host for this pool | Required |
primary |
Whether this host is fallback primary (exactly one must be true) |
false |
health_check_interval |
Interval for background health checks | 300s |
health_check_timeout |
Timeout for proxy health checks | 10s |
min_available_proxies |
Min available proxies | 3 |
health_check_url |
URL to test proxy health | "https://www.google.com" |
retry_count |
Number of retries for failed requests | 3 |
retry_strategy |
Retry behavior | DefaultSelection |
selection_strategy |
Proxy selection algorithm | FastestResponse |
min_request_interval_ms |
Min interval per proxy request | 500 |
response_classifier |
Custom response classifier for proxy health | DefaultResponseClassifier |
danger_accept_invalid_certs |
Accept invalid TLS certs (needed for most free proxies) | false |
Host-Based Routing (Multiple Pools)
use ;
let api_host = builder.build;
let web_host = builder.primary.build;
let config = builder
.sources
.hosts
.build;
let middleware = new.await?;
Routing Rules
- Request host matches a configured
HostConfig.host-> use that host pool. - Request host does not match -> use the unique
HostConfigwithprimary(true).
primary=true is required for exactly one host.
Migration (0.2 -> 0.3)
ProxyPoolConfig(single pool config) -> split into:- top-level
ProxyPoolConfig { sources, hosts } - per-host
HostConfig
- top-level
max_requests_per_second->min_request_interval_msretry_strategyadded:DefaultSelection: previous behaviorNewProxyOnRetry: force different proxy on retries
Example migration:
// v0.2
// ProxyPoolConfig::builder().health_check_url(...).max_requests_per_second(3.0)
// v0.3
let host = builder
.primary
.health_check_url
.min_request_interval_ms
.build;
let config = builder
.sources
.add_host
.build;