This Docker image provides one HTTP proxy endpoint with many IP addresses for use scenarios like web crawling.
Behind the scene, it has a HAProxy sitting in front of multiple pairs of Privoxy-Tor. The HAProxy dispatches the incoming requests to the Privoxy instances with a round-robin strategy.
This image is multi-platform enabled, currently supporting:
- amd64 (x86_64)
- arm64 (aarch64)
- arm/v7 (armhf)
- arm/v6 (armel)
docker run --rm -it -p 3128:3128 zhaowde/rotating-tor-http-proxyAt the host, 127.0.0.1:3128 is the HTTP/HTTPS proxy address.
docker run --rm -it -p 3128:3128 -p 4444:4444 -e "TOR_INSTANCES=5" -e "TOR_REBUILD_INTERVAL=3600" -e "TOR_EXIT_COUNTRY=de,ch,at" zhaowde/rotating-tor-http-proxyPort 4444/TCP can be mapped to the host if HAProxy stats information is needed. With docker run -p 4444:4444, the HAProxy statistics
report is available at http://127.0.0.1:4444. An article from the
HAProxy official blog explains in detail how to understand this report.
Environment variable TOR_INSTANCES can be used to config the number of concurrent Tor clients (as well as the associated Privoxy
instances). The default is 10, and the valid value is purposely limited to the range between 1 and 40.
Each Tor client attempts to build a new circuit (results in a new outbound IP address) every 30 seconds. Every 30 minutes, this image
rebuilds all the circuits. This interval can be changed with environment variable TOR_REBUILD_INTERVAL, the default value is 1800
seconds, while it can be set up any number greater than 600 seconds.
For some crawling tasks, it requires limiting the IP addresses to a certain country to avoid triggering the unnecessary recaptcha verification.
Environment variable TOR_EXIT_COUNTRY can be used to specify a country (or a list of countries).
Please note the following remarks:
-
Note 1: Modifying the way that Tor creates its circuits is strongly discouraged, overriding the entry/exit nodes can compromise the anonymity.
-
Note 2: The tor bridge is configured to strictly respect the exit countries if it is specified. For the countries with too fewer exit nodes (e.g., Switzerland), it would take significantly longer time to build up the circuit.
-
Note 3: The environment variable accepts a single country code (e.g.,
TOR_EXIT_COUNTRY=de) or a comma-separated list (e.g.,TOR_EXIT_COUNTRY=de,at,ch) -
Note 4: The acceptable country codes:
Country Code Country Code Country Code Country Code Country Code Country Code ASCENSION ISLAND acAFGHANISTAN afALAND axALBANIA alALGERIA dzANDORRA adANGOLA aoANGUILLA aiANTARCTICA aqANTIGUA AND BARBUDA agARGENTINA REPUBLIC arARMENIA amARUBA awAUSTRALIA auAUSTRIA atAZERBAIJAN azBAHAMAS bsBAHRAIN bhBANGLADESH bdBARBADOS bbBELARUS byBELGIUM beBELIZE bzBENIN bjBERMUDA bmBHUTAN btBOLIVIA boBOSNIA AND HERZEGOVINA baBOTSWANA bwBOUVET ISLAND bvBRAZIL brBRITISH INDIAN OCEAN TERR ioBRITISH VIRGIN ISLANDS vgBRUNEI DARUSSALAM bnBULGARIA bgBURKINA FASO bfBURUNDI biCAMBODIA khCAMEROON cmCANADA caCAPE VERDE cvCAYMAN ISLANDS kyCENTRAL AFRICAN REPUBLIC cfCHAD tdCHILE clPEOPLE'S REPUBLIC OF CHINA cnCHRISTMAS ISLANDS cxCOCOS ISLANDS ccCOLOMBIA coCOMORAS kmCONGO cgCONGO (DEMOCRATIC REPUBLIC) cdCOOK ISLANDS ckCOSTA RICA crCOTE D IVOIRE ciCROATIA hrCUBA cuCYPRUS cyCZECH REPUBLIC czDENMARK dkDJIBOUTI djDOMINICA dmDOMINICAN REPUBLIC doEAST TIMOR tpECUADOR ecEGYPTegEL SALVADOR svEQUATORIAL GUINEA gqESTONIA eeETHIOPIA etFALKLAND ISLANDS fkFAROE ISLANDS foFIJI fjFINLAND fiFRANCE frFRANCE METROPOLITAN fxFRENCH GUIANA gfFRENCH POLYNESIA pfFRENCH SOUTHERN TERRITORIES tfGABON gaGAMBIA gmGEORGIA geGERMANY deGHANA ghGIBRALTER giGREECE grGREENLAND glGRENADA gdGUADELOUPE gpGUAM guGUATEMALA gtGUINEA gnGUINEA-BISSAU gwGUYANA gyHAITI htHEARD & MCDONALD ISLAND hmHONDURAS hnHONG KONG hkHUNGARY huICELAND isINDIA inINDONESIA idIRAN, ISLAMIC REPUBLIC OF irIRAQ iqIRELAND ieISLE OF MAN imISRAEL ilITALY itJAMAICA jmJAPAN jpJORDAN joKAZAKHSTAN kzKENYA keKIRIBATI kiKOREA, DEM. PEOPLES REP OF kpKOREA, REPUBLIC OF krKUWAIT kwKYRGYZSTAN kgLAO PEOPLE'S DEM. REPUBLIC laLATVIA lvLEBANON lbLESOTHO lsLIBERIA lrLIBYAN ARAB JAMAHIRIYA lyLIECHTENSTEIN liLITHUANIA ltLUXEMBOURG luMACAO moMACEDONIA mkMADAGASCAR mgMALAWI mwMALAYSIA myMALDIVES mvMALI mlMALTA mtMARSHALL ISLANDS mhMARTINIQUE mqMAURITANIA mrMAURITIUS muMAYOTTE ytMEXICO mxMICRONESIA fmMOLDAVA REPUBLIC OF mdMONACO mcMONGOLIA mnMONTENEGRO meMONTSERRAT msMOROCCO maMOZAMBIQUE mzMYANMAR mmNAMIBIA naNAURU nrNEPAL npNETHERLANDS ANTILLES anNETHERLANDS, THE nlNEW CALEDONIA ncNEW ZEALAND nzNICARAGUA niNIGER neNIGERIA ngNIUE nuNORFOLK ISLAND nfNORTHERN MARIANA ISLANDS mpNORWAY noOMAN omPAKISTAN pkPALAU pwPALESTINE psPANAMA paPAPUA NEW GUINEA pgPARAGUAY pyPERU pePHILIPPINES (REPUBLIC OF THE) phPITCAIRN pnPOLAND plPORTUGAL ptPUERTO RICO prQATAR qaREUNION reROMANIA roRUSSIAN FEDERATION ruRWANDA rwSAMOA wsSAN MARINO smSAO TOME/PRINCIPE stSAUDI ARABIA saSCOTLAND ukSENEGAL snSERBIA rsSEYCHELLES scSIERRA LEONE slSINGAPORE sgSLOVAKIA skSLOVENIA siSOLOMON ISLANDS sbSOMALIA soSOMOA,GILBERT,ELLICE ISLANDS asSOUTH AFRICA zaSOUTH GEORGIA, SOUTH SANDWICH ISLANDS gsSOVIET UNION suSPAIN esSRI LANKA lkST. HELENA shST. KITTS AND NEVIS knST. LUCIA lcST. PIERRE AND MIQUELON pmST. VINCENT & THE GRENADINES vcSUDAN sdSURINAME srSVALBARD AND JAN MAYEN sjSWAZILAND szSWEDEN seSWITZERLAND chSYRIAN ARAB REPUBLIC syTAIWAN twTAJIKISTAN tjTANZANIA, UNITED REPUBLIC OF tzTHAILAND thTOGO tgTOKELAU tkTONGA toTRINIDAD AND TOBAGO ttTUNISIA tnTURKEY trTURKMENISTAN tmTURKS AND CALCOS ISLANDS tcTUVALU tvUGANDA ugUKRAINE uaUNITED ARAB EMIRATES aeUNITED KINGDOM (no new registrations) gbUNITED KINGDOM ukUNITED STATES usUNITED STATES MINOR OUTL.IS. umURUGUAY uyUZBEKISTAN uzVANUATU vuVATICAN CITY STATE vaVENEZUELA veVIET NAM vnVIRGIN ISLANDS (USA) viWALLIS AND FUTUNA ISLANDS wfWESTERN SAHARA ehYEMEN yeZAMBIA zmZIMBABWE zw
while :; do curl -sx localhost:3128 ifconfig.io; echo ""; sleep 2; doneAt GitHub, there are many repos build Docker images to provide HTTP proxy connects to the Tor network. The project is reinventing the wheels based on many of them. Remarkably:
- y4ns0l0/docker-multi-tor creates a setup with multiple pairs of Privoxy-Tor. Having no HAProxy-like dispatcher, each Privoxy expose itself to the host as a different TCP port.
- mattes/rotating-proxy does exactly the same job as this project. However,
- it utilizes Polipo as the HTTP-SOCKS proxy adapter. Polipo ceased to be maintained on 6 November 2016
- the base image is Ubuntu 14.04, which it too heavy for this case, and out-of-maintenance as well
- the main control logic is written in Ruby
- alpine-3.21.2
- bash-5.2.37
- curl-8.11.1
- haproxy-3.0.7
- privoxy-3.0.34
- sed-4.9
- tor-0.4.8.13
