How It Works
SmartProxyMiddleware uses intelligent escalation:- Direct connections first - Fast and free
- Detect blocking - Automatic detection of 403/429 errors
- Datacenter proxy fallback - Cheap, fast option
- Learn domain patterns - Remembers which domains need proxies
- Expert-in-the-loop - Asks before using expensive residential proxies
Smart cost control: Direct connections when possible, datacenter proxies for blocks, residential proxies only with explicit approval. Reduces proxy costs by 80-90%.
Setup
Add proxy credentials to.env:
Usage
Auto Mode (Default) - Expert-in-the-Loop
Explicit Proxy Modes
Configuration
The middleware is enabled by default insettings.py with priority 350.
Statistics Tracking
SmartProxyMiddleware tracks detailed usage statistics:- Direct requests - Connections without proxy
- Proxy requests - Connections using proxy
- Blocked retries - Requests that hit 403/429 and retried with proxy
- Blocked domains - Domains that consistently need proxies
Proxy Providers
SmartProxyMiddleware works with any HTTP proxy provider. Popular options include Bright Data, Oxylabs, IPRoyal, Smartproxy, and others.Troubleshooting
Proxy Not Being Used
1
Check .env configuration
Verify all 4 variables are set (USERNAME, PASSWORD, HOST, PORT)
2
Verify credentials
Ensure proxy credentials are correct
3
Test proxy manually
4
Check logs
Look for “Datacenter proxy available” message on spider start
Still Getting Blocked with Proxy
1
Check if proxy IP is blocked
Proxy IP may already be blocked by target site
2
Try different provider
Switch to alternative proxy provider
3
Add delays
Increase
DOWNLOAD_DELAY in spider config:4
Reduce concurrency
Lower
CONCURRENT_REQUESTS in spider config:Proxy Costs Too High
SmartProxyMiddleware should already minimize costs by using direct connections first.
- Check which domains are marked as blocked (in stats at spider close)
- Verify those domains actually need proxies
- Consider if site has changed and unblocking is possible
- Some sites may require proxies for all requests - this is expected
Related Guides
Cloudflare Bypass
Handle Cloudflare-protected sites
Checkpoint Resume
Pause and resume long crawls