Sign inSign up

lahiru98s/docker-socks5-proxy

By lahiru98s

Updated 4 months ago

Image
0

1.6K

lahiru98s/docker-socks5-proxy repository overview

docker-socks5-proxy

A production-ready, lightweight SOCKS5 proxy server built on Dante and Alpine Linux. Single ~15MB image, zero runtime dependencies, fully configurable via environment variables.

Docker Hub Image Size License: MIT


Features

FeatureDescription
SOCKS5 protocolFull TCP support with optional UDP ASSOCIATE via Dante
Flexible authenticationOpen proxy, single user, or multi-user with file or env
IP allowlistRestrict access to specific source CIDRs
Destination filteringBlock outbound access to IPs or subnets
IPv6 supportOptional dual-stack internal listener
Custom DNSOverride the container resolver to prevent DNS leaks
Configurable timeoutsFine-tune connect, negotiate, and idle session timeouts
Tor routingOne env var routes all traffic through the Tor network
Quiet log modeSuppress per-connection logs for high-throughput deployments
Graceful reloadSend SIGHUP to hot-reload config without container restart
Health checkDocker HEALTHCHECK reports true proxy availability
Performance tunedKernel TCP tuning, fd limits, Dante worker pre-forking

Quick Start

docker run -d \
  --name socks5-server \
  --restart unless-stopped \
  -p 54178:1080 \
  lahiru98s/docker-socks5-proxy:latest

With authentication:

docker run -d \
  --name socks5-server \
  --restart unless-stopped \
  -p 54178:1080 \
  -e PROXY_USER=alice \
  -e PROXY_PASS=secret \
  lahiru98s/docker-socks5-proxy:latest

With Docker Compose using the prebuilt image:

curl -O https://raw.githubusercontent.com/nooblk-98/docker-socks5-proxy/main/docker-compose.prebuilt.yml
docker compose -f docker-compose.prebuilt.yml up -d
Option 2 — Build from source
git clone https://github.com/nooblk-98/docker-socks5-proxy.git
cd docker-socks5-proxy
cp .env.example .env
# Edit .env as needed
docker compose up -d --build

The proxy listens on port 54178 by default (configurable via SOCKS5_PORT).


Configuration Reference

VariableDefaultDescription
SOCKS5_PORT54178Host port mapped to the SOCKS5 listener
PROXY_USER(empty)Single username — leave empty for open proxy
PROXY_PASS(empty)Single user password
PROXY_USERS(empty)Comma-separated user:pass pairs (overrides single user)
ALLOWED_CIDR(empty)Comma-separated source CIDRs permitted to connect (empty = all)
BLOCKED_DESTINATIONS(empty)Comma-separated destination IPs/CIDRs to block outbound
UDP_ENABLEDfalseEnable SOCKS5 UDP ASSOCIATE
IPV6_ENABLEDfalseAdd an IPv6 internal listener (:: 1080)
DNS_SERVER(empty)Override container DNS resolver (e.g. 1.1.1.1)
TIMEOUT_CONNECT30TCP connect timeout in seconds
TIMEOUT_NEGOTIATE30SOCKS5 negotiation timeout in seconds
TIMEOUT_IO86400Idle session timeout in seconds
TOR_ENABLEDfalseRoute all outbound traffic through Tor
LOG_LEVELnormalSet to quiet to suppress connect/disconnect logs

Authentication

Open proxy (no auth)

Leave PROXY_USER and PROXY_PASS unset (default behavior).

Single user
PROXY_USER=alice
PROXY_PASS=secret
Multiple users via environment variable
PROXY_USERS=alice:secret,bob:hunter2,carol:p@ssw0rd
Multiple users via file

Create a users.txt file — one user:pass per line, lines starting with # are ignored:

# Proxy users
alice:secret
bob:hunter2

Mount it in docker-compose.yml:

volumes:
  - ./users.txt:/etc/proxy-users.txt:ro

IP Allowlist

Restrict inbound connections to specific source CIDRs. All other clients are blocked.

ALLOWED_CIDR=203.0.113.0/24,198.51.100.5/32

Destination Filtering

Block outbound access to specific IPs or subnets — useful for preventing access to internal networks:

BLOCKED_DESTINATIONS=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16

UDP Support

Enable the SOCKS5 UDP ASSOCIATE command for DNS and UDP-based applications:

UDP_ENABLED=true

IPv6

Bind an additional :: listener to accept connections from IPv6 clients:

IPV6_ENABLED=true

Docker's default network is IPv4-only. To use IPv6, enable enable_ipv6 in your Docker daemon configuration.


Custom DNS

Point the container at a specific DNS resolver to prevent leaks:

DNS_SERVER=1.1.1.1

Configurable Timeouts

TIMEOUT_CONNECT=30      # Seconds to establish an outbound TCP connection
TIMEOUT_NEGOTIATE=30    # Seconds allowed for the SOCKS5 handshake
TIMEOUT_IO=3600         # Idle session timeout (seconds)

Tor Routing

Route all proxied traffic through the Tor network with a single variable:

TOR_ENABLED=true

Dante forwards all connections to Tor's local SOCKS5 port (9050). The Tor daemon starts automatically inside the container.

The first connection after startup may be slow while Tor builds its circuits.


Log Level

For high-throughput deployments, suppress per-connection log entries to reduce I/O overhead:

LOG_LEVEL=quiet

When set to quiet, only errors are logged. Default is normal (connect/disconnect/error).


Graceful Config Reload

Send SIGHUP to reload Dante's configuration without restarting the container or dropping active connections:

docker kill --signal=HUP socks5-server

Tag summary

Content type

Image

Digest

sha256:bab7d498d

Size

11.1 MB

Last updated

4 months ago

docker pull lahiru98s/docker-socks5-proxy