Skip to main content

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

rotating_mitmproxy-1.3.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotating_mitmproxy-1.3.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file rotating_mitmproxy-1.3.0.tar.gz.

File metadata

  • Download URL: rotating_mitmproxy-1.3.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for rotating_mitmproxy-1.3.0.tar.gz
Algorithm Hash digest
SHA256 70c51ef1ca61b24b956b3b5ae7ce73459d77322dc008f8d341d25e994ed184a3
MD5 9c6e3986b4610072bbdf0a9b4990b744
BLAKE2b-256 af5b44fd15921846e6970b9d8e15d2c45e3d8e9ac639e34a918d13c08d3cc688

See more details on using hashes here.

File details

Details for the file rotating_mitmproxy-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rotating_mitmproxy-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad66eeae570ae3326c739269e7d3ee299560d313f002e6c74259d8d1000739ce
MD5 347753dd3e4d20257b69517bf2bb4d5b
BLAKE2b-256 b2934a64adb097e407b358092f99848d71ff91a6215581f8f9b78a20593a1fa7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page