This document describes all supported configuration keys for socks2proxy.
It reflects current runtime and --check validation behavior.
listen: ":41080"
allowed_client_addresses:
- "172.31.11.0/24"
- "127.0.0.1/32"
tls:
insecure_skip_verify: false
min_version: "1.2"
routing:
default:
method: "reject"
source_ip: "127.0.0.1"
rules:
- dst_ports: [80]
dst_addresses: ["0.0.0.0/0", "::/0"]
method: "http"
upstream: "http://proxy.example.com:3128"
source_ip: "127.0.0.1"
- dst_ports: [443]
dst_addresses: ["0.0.0.0/0", "::/0"]
method: "connect"
upstream: "http://proxy.example.com:3128"
source_ip: "127.0.0.1"
- dst_ports: [22]
dst_addresses: ["0.0.0.0/0", "::/0"]
method: "direct"
source_ip: "127.0.0.1"
- dst_ports: [25]
dst_addresses: ["0.0.0.0/0", "::/0"]
method: "reject"
timeouts:
connect: "10s"
idle: "300s"
http:
max_header_bytes: 65536
logging:
level: "info"| Key | Type | Required | Description |
|---|---|---|---|
listen |
string | yes | TCP listen address for SOCKS5 server. |
allowed_client_addresses |
list[string] | yes | Client source address allowlist (single IP, CIDR, or IP range). |
tls |
object | no | Global TLS defaults for HTTPS upstream proxy connections. |
routing |
object | yes | Routing rules by destination ports/addresses plus optional default rule. |
timeouts |
object | yes | Connect and idle timeout values. |
http |
object | yes | HTTP parser/server limits. |
logging |
object | yes | Logging settings. |
- Format: Go TCP address format, for example:
":41080"(all interfaces, port 41080)"127.0.0.1:41080""[::1]:41080"
- Validation:
- must resolve as TCP listen address
- port must be in range
1..65535
List of source client address selectors allowed to connect to the SOCKS5 listener.
Accepted forms (scalar or list, CSV supported):
- single IP (for example
10.0.0.10) - CIDR (for example
10.0.0.0/24) - IP range (for example
10.0.0.10-10.0.0.50)
Notes:
- Each entry must be a valid address selector.
- If a client IP does not match any selector, connection is denied.
Routing has two parts:
routing.rules: first-match rules by destination selectors (dst_port(s),dst_address(es), or both)routing.default: fallback when no rule matches
routing.default is optional.
If routing.default is not specified, an implicit fallback is used:
routing:
default:
method: "reject"That means unmatched ports are rejected unless you set another default.
| Field | Type | Required | Description |
|---|---|---|---|
dst_ports / dst_port |
list/scalar | conditional | Destination TCP port selector(s); accepts list or comma-separated/range scalar. If omitted, any destination port matches. |
dst_addresses / dst_address |
list/scalar | conditional | Destination address selector(s); accepts list or comma-separated scalar. If omitted, any destination address matches. |
method |
string | yes | One of http, connect, direct, reject. |
upstream |
string | conditional | Required for http and connect; forbidden for direct and reject. |
source_ip |
string | optional | Local source IP used to bind outbound sockets for this rule before dialing target/upstream. |
tls |
object | optional | Optional HTTPS upstream TLS settings. |
| Field | Type | Required | Description |
|---|---|---|---|
method |
string | yes | One of http, connect, direct, reject. |
upstream |
string | conditional | Required for http and connect; forbidden for direct and reject. |
source_ip |
string | optional | Local source IP used to bind outbound sockets when the default rule dials target/upstream. |
tls |
object | optional | Optional HTTPS upstream TLS settings. |
-
http- Reads HTTP/1.x request from client.
- Sends absolute-form request to upstream proxy.
-
connect- Sends upstream
CONNECT host:port. - On success, tunnels bytes bidirectionally.
- Sends upstream
-
direct- Opens direct TCP connection to target host:port.
- Does not use upstream proxy.
-
reject- Rejects request immediately.
- Preferred format: URL with scheme:
http://proxy.example.com:3128https://proxy.example.com:8443
- Validation:
- URL scheme must be
httporhttps - host must be non-empty
- port must be numeric and in
1..65535
- URL scheme must be
tls may be defined only when upstream uses https://.
| Key | Type | Default | Description |
|---|---|---|---|
insecure_skip_verify |
bool | false |
Disables certificate chain and hostname verification (not recommended). |
ca_cert_file |
string | unset | Path to PEM certificate bundle used as root CA store for this upstream. |
min_version |
string | 1.2 |
Minimum TLS version for HTTPS upstream handshake (1.2 or 1.3). |
Behavior:
- Default (no
tlsblock): verify certificate and hostname using system CA trust store. - With
ca_cert_file: use provided PEM bundle as root CAs for this upstream. min_versioncontrols minimum TLS version for HTTPS upstream (1.2or1.3).tlsoptions withhttp://upstream are invalid.
You can define a top-level tls block to set defaults for HTTPS upstream proxy
connections:
tls:
insecure_skip_verify: false
min_version: "1.2"Resolution order:
- Per-rule/default
tlsblock, if present. - Top-level
tlsblock, if present. - Built-in defaults (
insecure_skip_verify: false, system trust store,min_version: "1.2").
Important:
- Per-rule/default
tlsfully overrides top-leveltls(it is not field-wise merged). - Top-level
tlsis ignored for non-HTTPS upstream URLs.
- First
routing.rulesmatch in list order (port + address match) routing.defaultfallback- If no
routing.defaultconfigured, implicitreject
Selector semantics:
- If a rule defines both port and address selectors, both must match.
- If a rule omits
dst_port(s), port matching is wildcard (any). - If a rule omits
dst_address(es), address matching is wildcard (any). - A rule must define at least one selector type (port and/or address).
source_ip semantics:
- If set,
socks2proxybinds the outbound socket to this local IP before dialing. - Applies to
direct,http, andconnectmethods. - Works for both
routing.rules[]androuting.default.
- each expanded port value from
dst_port(s)must be in1..65535. - each
dst_addressesentry must be one of:- single IP (for example
10.0.0.10) - CIDR (for example
10.0.0.0/24) - IP range (for example
10.0.0.10-10.0.0.50)
- single IP (for example
methodmust be one ofhttp,connect,direct,reject.source_ip, when set, must be a valid literal IPv4 or IPv6 address.
Duration values use Go duration syntax (10s, 300ms, 2m, etc.).
| Key | Type | Required | Description |
|---|---|---|---|
connect |
duration string | yes | Dial timeout for upstream/direct target connection. |
idle |
duration string | yes | Connection idle timeout for client/upstream/target sockets. |
Validation:
- all timeout values must be greater than
0.
| Key | Type | Required | Description |
|---|---|---|---|
max_header_bytes |
int | yes | Max header read buffer size for client HTTP request parsing. |
Validation:
- must be greater than
0.
| Key | Type | Required | Allowed values | Description |
|---|---|---|---|---|
level |
string | yes | debug, info, warn, error |
Log verbosity threshold. |
Validation:
- unknown values cause startup/check failure.
- Validation runs when loading config for normal runtime.
- Validation also runs for
--checkmode. - If CLI overrides are used (for example
--log-level), config is re-validated. - Any invalid value causes immediate exit with an error.
routing:
rules:
- dst_ports: [443]
dst_addresses: ["0.0.0.0/0", "::/0"]
method: "connect"
upstream: "http://proxy.example.com:3128"Unmatched ports are rejected because routing.default is omitted.
routing:
default:
method: "direct"
rules:
- dst_ports: [443]
dst_addresses: ["0.0.0.0/0", "::/0"]
method: "connect"
upstream: "http://proxy.example.com:3128"routing:
default:
method: "connect"
upstream: "https://proxy.example.com:8443"
rules:
- dst_ports: [80]
dst_addresses: ["0.0.0.0/0", "::/0"]
method: "http"
upstream: "https://proxy.example.com:8443"method: "direct"withupstreamset -> invalid (upstream forbidden).method: "reject"withupstreamset -> invalid (upstream forbidden).method: "http"or"connect"withoutupstream-> invalid (upstream required).- missing both destination selector types in a rule -> invalid (at least one of port/address is required).
- invalid
source_ipvalue (not a literal IP) -> invalid. logging.level: "verbose"-> invalid (not in allowed set).listen: ":0"-> invalid (port out of allowed range).