This project provides a Dockerized Tor proxy server that routes your internet traffic through the Tor network using a SOCKS5 proxy with DNS support.
Disclaimer: This project is intended for legitimate and legal use only, such as privacy protection, censorship circumvention, and security research. Users are solely responsible for ensuring their usage complies with applicable laws and regulations. The maintainers of this project are not responsible for any misuse.
- SOCKS5 proxy with DNS resolution through Tor
- Runs inside a Docker container for easy deployment
- No need to install Tor or configure it manually on your host
- Supports both HTTP and HTTPS traffic routing via SOCKS5
- Available on both Docker Hub and GitHub Container Registry (GHCR)
- Multi-architecture support (linux/amd64, linux/arm64)
- Built-in container healthcheck
- Runs as non-root user for improved security
- Configurable via environment variables
- Tor Bridge support (obfs4, meek) for censored networks
- Exit node country selection
- Multi-instance load balancing with HAProxy
- Persistent Tor data for faster reconnection
- Container image signing with cosign
- Trivy vulnerability scanning in CI
- Docker installed on your system
- Basic knowledge of Docker commands
git clone https://github.com/mstfknn/tor-proxy.git
cd tor-proxy
cp .env.example .env
docker compose up -dThen test it:
curl --socks5-hostname localhost:9150 https://check.torproject.org/api/ipYou can pull images directly from Docker Hub or GHCR:
Docker Hub
docker pull mstfknn/tor-proxy:debian
docker pull mstfknn/tor-proxy:alpineFor bridge support (obfs4, meek):
docker pull mstfknn/tor-proxy:debian-bridge
docker pull mstfknn/tor-proxy:alpine-bridgeGitHub Container Registry (GHCR)
docker pull ghcr.io/mstfknn/tor-proxy:debian
docker pull ghcr.io/mstfknn/tor-proxy:alpinedocker run -d --name tor-proxy -p 9150:9150 -p 8853:5353/udp mstfknn/tor-proxy:debian- Port
9150→ SOCKS5 proxy - Port
8853→ DNS resolution through Tor
docker run -d --name tor-proxy-alpine -p 9150:9150 -p 8853:5353/udp mstfknn/tor-proxy:alpinecp .env.example .env # customize if needed
docker compose up -dSet your application's SOCKS5 proxy to localhost:9150.
DNS requests will be routed through Tor automatically via port 8853.
| Variable | Default | Description |
|---|---|---|
SOCKS_PORT |
9150 |
SOCKS5 proxy port |
DNS_PORT |
5353 |
DNS resolution port |
ENABLE_LOG |
false |
Enable Tor logging to stdout (docker logs) |
EXIT_NODES |
- | Exit node countries (e.g., {US},{DE}) |
STRICT_NODES |
0 |
Only use specified exit nodes (1 to enable) |
USE_BRIDGE |
false |
Enable Tor bridge |
BRIDGE_TYPE |
- | Bridge type: obfs4, meek, snowflake |
BRIDGE_LINES |
- | Bridge addresses (semicolon-separated) |
Route your traffic through specific countries:
docker run -d --name tor-proxy -p 9150:9150 \
-e EXIT_NODES="{US},{GB},{DE}" \
-e STRICT_NODES=1 \
mstfknn/tor-proxy:debianFor networks where Tor is blocked, use the -bridge tagged images which include obfs4proxy:
docker run -d --name tor-proxy -p 9150:9150 \
-e USE_BRIDGE=true \
-e BRIDGE_TYPE=obfs4 \
-e BRIDGE_LINES="obfs4 1.2.3.4:443 FINGERPRINT cert=... iat-mode=0" \
mstfknn/tor-proxy:debian-bridgeYou can get bridge addresses from https://bridges.torproject.org.
Keep Tor state across container restarts for faster reconnection:
docker run -d --name tor-proxy -p 9150:9150 \
-v tor-data:/var/lib/tor \
mstfknn/tor-proxy:debianRun multiple Tor instances behind HAProxy for improved speed and different exit IPs per request:
docker compose -f docker-compose.multi.yml up -dThis starts 3 Tor instances with HAProxy round-robin on port 9150. Each request exits through a different Tor circuit. No additional image build is required — it uses the pre-built mstfknn/tor-proxy:debian image from Docker Hub and the official haproxy:alpine image.
Client → :9150 → HAProxy → tor-1 (circuit A)
→ tor-2 (circuit B)
→ tor-3 (circuit C)
- Container images are signed with cosign for supply chain security
- Trivy vulnerability scanning runs on every build
- Tor runs as a non-root user inside the container
- Minimal base images (Debian slim / Alpine) reduce attack surface
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.
