🧅 TorSocksBag is a Docker project for running multiple TOR SOCKS proxies in one container at once.
The project is suitable for those who want to deploy quickly:
- TOR proxy cluster on a local machine or server
- Multiple SOCKS5 ports for distributed operation
- Support for obfuscation via OBFS4 bridges
- Automatic monitoring and restart of fallen instances
- Multi-TOR instances with a separate
SocksPorton each proxy - Batch container assembly via
docker-compose - Configurable number of proxies via
.env - File
templates/bridges.txtfor obfs4 bridges - Control via
tor-manager.sh - Separate TOR data storage in Docker volume
tor-data
docker-compose.yaml— service and volume mountingDockerfile— image based ondebian:stable-slimwith TOR and obfs4proxyentrypoint.sh— launches the TOR cluster and organizes monitoringtor-manager.sh— cluster management shell.env/.env.Example— basic startup parameterstemplates/torrc.template— TOR configuration templatetemplates/bridges.txt— obfs4 bridges for bypassing locks
-
Copy the configuration example:
copy .env.Example .env
-
If necessary, change the parameters in
.env:START_PORT— the starting port for the first SOCKS5 proxyPROXY_COUNT— the number of TOR instancesEND_PORT— end port for forwardingCONTROL_BASE_PORT— base port for ControlPort (if enabled)ENABLE_CONTROL— enable control via ControlPortUSE_BRIDGES— use bridges fromtemplates/bridges.txtTOR_LOG_LEVEL— logging level:notice,info,debugENABLE_MONITORING— auto-restart of crashed processes
-
Start the cluster:
bash tor-manager.sh start
-
Check the status:
bash tor-manager.sh status
The container creates a 'PROXY_COUNT` of TOR instances. Each instance listens to its SOCKS port:
START_PORTSTART_PORT + 1- ...
START_PORT + PROXY_COUNT - 1
For example, with START_PORT=9050 and PROXY_COUNT=10, ports 9050–9059 will be created.
entrypoint.sh generates a configuration for each instance and runs TOR in the background. If ENABLE_MONITORING=true is enabled, the process is monitored and automatically restarts when it crashes.
START_PORT=9050
PROXY_COUNT=10
END_PORT=9060
CONTROL_BASE_PORT=9050
ENABLE_CONTROL=false
USE_BRIDGES=true
TOR_LOG_LEVEL=notice
ENABLE_MONITORING=true- Telegram: @GetBridgesBot
- https://bridges.torproject.org
- Email address: bridges@torproject.org (a message with the text
get transport obfs4)
If USE_BRIDGES=true, the container reads bridges from templates/bridges.txt .
To get fresh bridges, use the services of the Tor Project or other trusted sources.
| Team | Description |
|---|---|
start |
Build and launch a container in the background |
stop |
Stop the cluster |
restart |
Restart the container |
status |
Show the status of the container and TOR ports |
logs |
Monitor container logs |
newnym |
Request new TOR schemas (requires ENABLE_CONTROL=true) |
check |
Test all SOCKS proxies and show the IP |
bash tor-manager.sh start
bash tor-manager.sh status
bash tor-manager.sh logs
bash tor-manager.sh check
bash tor-manager.sh newnymTo request new TOR chains (NEWNM), enable ENABLE_CONTROL=true and restart the container.
After launching, make sure that the proxies are working.:
curl --socks5-hostname localhost:9050 https://check.torproject.orgOr check all ports with one command.:
bash ./tor-manager.sh checkOr other apps:
Python:
import requests
from itertools import cycle
PROXIES = [
"socks5h://127.0.0.1:9050",
"socks5h://127.0.0.1:9051",
"socks5h://127.0.0.1:9052",
"socks5h://127.0.0.1:9053",
"socks5h://127.0.0.1:9054",
"socks5h://127.0.0.1:9055",
"socks5h://127.0.0.1:9056",
"socks5h://127.0.0.1:9057",
"socks5h://127.0.0.1:9058",
"socks5h://127.0.0.1:9059",
]
proxy_pool = cycle(PROXIES)
def fetch_with_rotation(url):
proxy = next(proxy_pool)
try:
response = requests.get(
url,
proxies={"http": proxy, "https": proxy},
timeout=15
)
return response.text, proxy
except Exception as err:
print(f"Error {proxy}: {err}")
return None, proxy
if __name__ == "__main__":
for i in range(5):
html, used_proxy = fetch_with_rotation("https://httpbin.org/ip")
print(f"Request {i+1}: {used_proxy}")
print(html[:200] if html else "Failed")docker-compose.yamlmounts:
./templates/bridges.txt→/etc/tor/bridges.txt- volume
tor-data→/var/lib/tor
This ensures that the TOR data is saved when the container is restarted.
ENABLE_CONTROL=falseby default to close _ControlPort from external access.- If you use bridges, make sure that
templates/bridges.txtcontains only verified obfs4 addresses. Sandbox 0is disabled in the configuration for compatibility inside the container.- We recommend running the project on a separate trusted host if you are working with TOR in production.
- You can add your own bridges to
templates/bridges.txt - Change
TOR_LOG_LEVELtoinfofor more detailed logging - Increase the
PROXY_COUNTto100for a large proxy pool - Connect each SOCKS port in a separate application to balance the load
Enjoying the tool? Drop a Star. Thanks and good luck!
MIT License
