Smart proxy rotator built on mitmproxy with health monitoring and failover
Project description
Rotating MitmProxy
A smart proxy rotator built on mitmproxy that automatically rotates through multiple upstream proxies with health monitoring and failover.
Features
- Smart Proxy Rotation: Round-robin, random, fastest, and smart selection strategies
- Health Monitoring: Real-time proxy health scoring and automatic failover
- High Concurrency: Handles 100+ concurrent requests efficiently
- Multiple Formats: Supports HTTP/SOCKS proxies with authentication
- Web Dashboard: Real-time statistics and monitoring interface
Installation
pip install rotating-mitmproxy
Quick Start
1. Create a proxy list file
# proxy_list.txt
proxy1.example.com:8080
proxy2.example.com:8080
user:pass@proxy3.example.com:8080
socks5://proxy4.example.com:1080
2. Start the proxy server
python -m rotating_mitmproxy --proxy-list proxy_list.txt --port 3129
3. Use the proxy
import requests
proxies = {
'http': 'http://localhost:3129',
'https': 'http://localhost:3129'
}
response = requests.get('https://httpbin.org/ip', proxies=proxies)
print(response.json())
Command Line Options
python -m rotating_mitmproxy [OPTIONS]
Options:
--proxy-list FILE Path to proxy list file (required)
--port PORT Listen port (default: 3129)
--strategy STRATEGY Selection strategy: round-robin, random, fastest, smart (default: smart)
--health-check Enable health checking (default: enabled)
--web-port PORT Web dashboard port (default: 8081, 0 to disable)
--verbose LEVEL Verbosity: quiet, normal, verbose (default: normal)
Proxy List Format
The proxy list file supports multiple formats:
# HTTP proxies
proxy1.example.com:8080
user:pass@proxy2.example.com:8080
# SOCKS proxies
socks5://proxy3.example.com:1080
socks5://user:pass@proxy4.example.com:1080
# With protocol specification
http://proxy5.example.com:8080
https://proxy6.example.com:8080
Selection Strategies
- round-robin: Cycles through proxies in order
- random: Selects proxies randomly
- fastest: Prefers proxies with lowest response times
- smart: Combines health scoring with performance metrics (recommended)
Web Dashboard
Access the web dashboard at http://localhost:8081 to view:
- Real-time proxy statistics
- Health scores and response times
- Success/failure rates
- Active connections
Programmatic Usage
from rotating_mitmproxy import RotatingProxy
# Start proxy server
proxy = RotatingProxy(
proxy_list_file="proxy_list.txt",
port=3129,
strategy="smart"
)
proxy.start()
# Use with requests
import requests
proxies = {'http': 'http://localhost:3129', 'https': 'http://localhost:3129'}
response = requests.get('https://httpbin.org/ip', proxies=proxies)
# Stop server
proxy.stop()
Health Monitoring
The system automatically monitors proxy health by:
- Tracking response times and success rates
- Scoring proxies based on performance
- Temporarily disabling failed proxies
- Gradually re-enabling recovered proxies
Configuration
Environment variables:
export ROTATING_PROXY_LIST="proxy_list.txt"
export ROTATING_PROXY_PORT="3129"
export ROTATING_PROXY_STRATEGY="smart"
export ROTATING_PROXY_WEB_PORT="8081"
Testing
# Run tests
python -m pytest tests/ -v
# Test with example
python examples/basic_example.py
License
MIT License - see LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rotating_mitmproxy-1.1.0.tar.gz.
File metadata
- Download URL: rotating_mitmproxy-1.1.0.tar.gz
- Upload date:
- Size: 23.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998be2b6be352869d8aa859a215cee07d9ca25d28d2c426060917a627aebf499
|
|
| MD5 |
3241992e13873367d77d150af63114a4
|
|
| BLAKE2b-256 |
6dad4129bafa5fb96cc61ae1f1cd173ffee7fc6e5b89669c9281c9df5e5d7ba5
|
File details
Details for the file rotating_mitmproxy-1.1.0-py3-none-any.whl.
File metadata
- Download URL: rotating_mitmproxy-1.1.0-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28b48089ad43716201a10c1c9e5ff8fd126eff345dd3a4d1e0372fb6a7558115
|
|
| MD5 |
b24853ca897226df4f80d4528fef33cd
|
|
| BLAKE2b-256 |
df32f85a5b6186b3d946e47a5f4746522df93f9d72925faf0deb247743086644
|