Minimal Tor HTTP & SOCKS5 proxy for Docker with API and health checks.
319
A minimal HTTP and SOCKS5 proxy that routes traffic through the Tor network. It is designed for simple, reliable Docker deployments and includes a small REST API plus a readiness-aware health check for automation.
811890508080Run the proxy with all services limited to the local machine:
docker run -d --name torproxy --restart unless-stopped \\
-p 127.0.0.1:8118:8118 \\
-p 127.0.0.1:9050:9050 \\
-p 127.0.0.1:8080:8080 \\
hapheus/torproxy:latest
Wait until the container is healthy, then verify the Tor exit IP:
docker inspect --format '{{.State.Health.Status}}' torproxy
curl -x http://127.0.0.1:8118 https://check.torproject.org/api/ip
curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip
Tor bootstrap can take a little time after the container starts.
| Port | Service | Use |
|---|---|---|
8118 | HTTP proxy | Configure HTTP/HTTPS-capable clients with http://127.0.0.1:8118. |
9050 | SOCKS5 proxy | Use 127.0.0.1:9050; clients should resolve hostnames through SOCKS5. |
8080 | REST API | Read status and control the Tor connection. |
For another container on the same Docker network, use torproxy:8118, torproxy:9050, or torproxy:8080 instead of 127.0.0.1.
The API returns JSON and accepts GET and POST where noted.
| Method | Endpoint | Description |
|---|---|---|
GET / POST | /status | Returns connecting, connected, or disconnected and the Tor IP when ready. |
GET | /ip | Returns the current Tor IP; responds with 503 while unavailable. |
GET / POST | /connect | Enables or resumes Tor network access. |
GET / POST | /disconnect | Disables Tor network access and blocks proxy traffic. |
GET / POST | /reconnect | Requests a new Tor circuit and clears the cached IP. |
curl http://127.0.0.1:8080/status
curl -X POST http://127.0.0.1:8080/reconnect
A new circuit does not guarantee a different exit IP: Tor can rate-limit circuit changes.
| Variable | Default | Description |
|---|---|---|
TORPROXY_LISTEN_ADDRESS | 0.0.0.0 | Address for the HTTP proxy inside the container. |
TORPROXY_LISTEN_PORT | 8118 | HTTP proxy port inside the container. |
TORPROXY_SOCKS_PORT | 9050 | Tor SOCKS5 port inside the container. |
TORPROXY_API_PORT | 8080 | REST API port inside the container. |
Example with a different published HTTP port:
docker run -d --name torproxy \\
-e TORPROXY_LISTEN_PORT=8118 \\
-p 127.0.0.1:18118:8118 \\
hapheus/torproxy:latest
Neither proxy endpoint nor the API has authentication. Keep ports 8118, 9050, and 8080 on a trusted local or private Docker network; do not expose them publicly.
Tor is not a guarantee of anonymity and does not encrypt traffic beyond the destination. Prefer https://, and use the image only for lawful, authorised activity that respects applicable terms, rate limits, and law.
Source code, Docker Compose example, and complete usage documentation: github.com/hapheus/torproxy
License: MIT
Content type
Image
Digest
sha256:fc62e0943…
Size
47.8 MB
Last updated
14 days ago
docker pull hapheus/torproxy