A portable Docker-based multi-Tor setup with HAProxy load balancing for enhanced anonymity and timing attack prevention.
- 4 Independent Tor Instances - Separate circuits for redundancy
- Random Load Balancing - HAProxy with
balance randomfor unpredictable routing - Privoxy Integration - HTTP proxy with content filtering
- Health Monitoring - Built-in HAProxy statistics dashboard
- Cross-Platform - Works on Linux, macOS, and Windows
- Docker (20.10+)
- Docker Compose (2.0+)
- 4GB RAM recommended
Use HAProxy's load-balanced endpoint:
# SOCKS5 proxy
curl -x socks5h://127.0.0.1:9999 https://check.torproject.org
# HTTP proxy via Privoxy
curl -x http://127.0.0.1:8118 https://check.torproject.org
# Configure applications
# Firefox: Settings β Network β SOCKS5: 127.0.0.1:9999
# Chrome: --proxy-server="socks5://127.0.0.1:9999"Access specific Tor instances (useful for proxychains):
# Tor instance 1
curl -x socks5h://127.0.0.1:9050 https://check.torproject.org
# Tor instance 2
curl -x socks5h://127.0.0.1:9051 https://check.torproject.org
# Tor instance 3
curl -x socks5h://127.0.0.1:9052 https://check.torproject.org
# Tor instance 4
curl -x socks5h://127.0.0.1:9053 https://check.torproject.orgSee docs/PROXYCHAINS_SETUP.md for detailed configuration.
Quick example:
proxychains4 curl https://check.torproject.org
proxychains4 nmap -sT target.com# All logs
docker-compose logs -f
# Specific service
docker-compose logs -f tor-loadbalancer
# Individual Tor instance logs
tail -f logs/tor1. out. log
tail -f logs/haproxy.out.log- Stream isolation per destination/port
- Regular circuit rotation (every 10 minutes)
- No relay/exit node operation
- Container security hardening (capabilities dropped)
- Cookie authentication for control ports
- Not a silver bullet - Tor provides anonymity, not invincibility
- Application leaks - Browser fingerprinting, WebRTC, DNS leaks can expose you
- Malicious exit nodes - Always use HTTPS for sensitive data
- Timing attacks - This setup reduces but doesn't eliminate correlation risks
- Tor over Tor - Using proxychains to chain Tor instances is controversial
- Use with Tails/Whonix - Combine with OS-level anonymity
2Browser hardening:
- Use Tor Browser or hardened Firefox
- Disable WebRTC:
media.peerconnection.enabled = false - Use HTTPS Everywhere / uBlock Origin
- Disable JavaScript for high-security scenarios
- DNS protection:
# Always use SOCKS5H (H = resolve hostnames via proxy) curl -x socks5h://127.0.0.1:9999 https://example.com - Clear data on shutdown - Run stop script and clear Tor data dirs
Edit configs/torrc1 through configs/torrc4:
# Exclude exit nodes from specific countries
ExcludeExitNodes {CN},{RU},{IR},{KP}
StrictNodes 1Country codes: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
# Rotate circuits more frequently (trade anonymity for freshness)
MaxCircuitDirtiness 300 # 5 minutes instead of 10
NewCircuitPeriod 15 # Consider new circuit every 15 secEdit configs/haproxy.cfg:
backend tor_backends
# Random (best for anti-timing attacks)
balance random
# OR Round-robin (predictable but evenly distributed)
# balance roundrobin
# OR Least connections (best for performance)
# balance leastconncurl -x socks5h://127.0.0.1:9999 https://check.torproject.orgShould output: "Congratulations. This browser is configured to use Tor."
# Without Tor
curl https://api.ipify.org
# Through Tor
curl -x socks5h://127.0.0.1:9999 https://api.ipify.orgIPs should be different!
# Bad (DNS leak)
curl -x socks5://127.0.0.1:9999 https://www.dnsleaktest.com
# Good (DNS via Tor)
curl -x socks5h://127.0.0.1:9999 https://www.dnsleaktest.comAlways use socks5h (with 'h') to resolve DNS through Tor!
for port in 9050 9051 9052 9053 9999; do
echo "Testing port $port:"
curl -x socks5h://127.0.0.1:$port https://api.ipify.org
doneShould show different IPs (unless circuits happen to share exit nodes).
# Check Docker is running
docker info
# View error logs
docker-compose logs
# Rebuild from scratch
docker-compose down -v
docker-compose up -d --build# Wait longer (can take 60+ seconds)
docker-compose logs -f | grep "Bootstrapped"
# Check if Tor ports are already in use
netstat -tulpn | grep -E "9050|9051|9052|9053"
# Restart with fresh circuits
./scripts/stop.sh
rm -rf data/tor*/*
./scripts/start.sh- Tor is inherently slower than direct connections
- Try different load balancing:
balance leastconnin haproxy.cfg - Increase
NumEntryGuardsin torrc files - Check HAProxy stats for unhealthy backends
# Fix data directory permissions
sudo chown -R 1000:1000 data/
chmod 700 data/tor*docker-compose down
docker-compose build --no-cache
docker-compose up -drm -rf data/tor1/* data/tor2/* data/tor3/* data/tor4/*tar -czf tor-config-backup-$(date +%Y%m%d).tar.gz config/This tool is provided for legitimate privacy and security purposes. Users are responsible for complying with all applicable laws. The authors do not condone illegal activity.
Tor is legal in most countries but may be restricted in some jurisdictions. Check local laws before use.
Improvements welcome! Consider:
- I2P integration
- Better health checking
- Vanguards
MIT License - See LICENSE file
- Tor Project
- HAProxy Documentation
- Privoxy Manual
- Proxychains GitHub
- Docker Security Best Practices
- The first address for using Tor: https://www.torproject.org/
- Tor Bridges: https://bridges.torproject.org/bridges?transport=obfs4
- Here are the Spec for Tor, here you can learn a lot about Tor: https://spec.torproject.org/
For issues or questions:
- Check the Troubleshooting section
- Review logs:
docker-compose logs - Open an issue on GitHub (if applicable)
- Consult Tor Project documentation
Stay safe, stay anonymous! π§ π
