3proxy · diff

v1.0.0 to v1.1.0

196 added, 125 removed. Audit A to A.

What this update changes in the checks

No check changed: every fixed check gives the same answer before and after this update.

A tripped check is a label, not a verdict: read the matched text and the lines below. This week's updates that newly trip a check.

---
name: 3proxy
description: >-
- Deploy and configure 3proxy — a lightweight universal proxy server. Use when a
- user asks to set up HTTP, HTTPS, SOCKS4, SOCKS5, or transparent proxies, build
- proxy chains, configure authentication, set bandwidth limits, manage access
- control lists, set up proxy rotation, create multi-port proxy servers,
- configure logging and traffic accounting, or deploy a lightweight proxy
- without heavy VPN overhead. Covers all 3proxy features including proxy
- chaining, ACLs, traffic shaping, and multi-protocol support.
+ 3proxy is a small open-source proxy server that runs HTTP/HTTPS, SOCKS4/5,
+ SNI and TCP/UDP port-mapping proxies from one config file. Use when a user
+ asks to set up an HTTP or SOCKS5 proxy, add proxy users and passwords, write
+ 3proxy access rules, chain or rotate upstream (parent) proxies, limit
+ bandwidth, connections or monthly traffic per user, run 3proxy in Docker, or
+ fix a 3proxy.cfg that will not start.
license: Apache-2.0
- compatibility: 'Linux, FreeBSD, Windows (3proxy 0.9+)'
+ compatibility: 'Linux, FreeBSD, macOS, Windows. 3proxy 1.0 (current) or 0.9.9.x (LTS)'
metadata:
author: terminal-skills
- version: 1.0.0
+ version: 1.1.0
category: devops
+ repository: https://github.com/3proxy/3proxy
tags:
- 3proxy
- proxy
- socks5
- http-proxy
- networking
---
# 3proxy
## Overview
- Deploy 3proxy — the tiny, fast, universal proxy server supporting HTTP(S), SOCKS4/5, port forwarding, and transparent proxying in a single ~200KB binary. Ideal for lightweight proxy setups, proxy chaining, multi-user access with traffic accounting, and scenarios where a full VPN is overkill. This skill covers installation, multi-protocol configuration, authentication, ACLs, bandwidth control, proxy chains, and production deployment.
+ 3proxy is a tiny proxy server: one binary (`3proxy`, about 330 KB in the 1.0.0 package) that starts HTTP(S), SOCKS4/5, SNI, FTP, POP3/SMTP and TCP/UDP port-mapping services from a single config file. The config is a script executed top to bottom — each line is a command, and a service line (`proxy`, `socks`, `tcppm`) starts with whatever `auth`, ACL and limits are in force at that point. This skill covers installation, the packaged file layout, users, ACLs, parent proxies, traffic limits and hardening.
## Instructions
### Step 1: Installation
- **From package manager:**
+ Debian and Ubuntu do not ship a `3proxy` package. The project publishes its own signed apt and dnf repositories (channels: `current` = 1.0, `lts` = 0.9.9.x).
+
```bash
- # Ubuntu/Debian
- apt update && apt install -y 3proxy
- # Config: /etc/3proxy/3proxy.cfg — Service: systemctl start 3proxy
+ # Debian 12+ / Ubuntu 22.04+
+ curl -fsSLO https://3proxy.org/repo/3proxy-release-key.asc
+ # verify the signing key's fingerprint before trusting it; stop if this prints nothing
+ gpg --show-keys --with-colons 3proxy-release-key.asc \
+ | grep -q '^fpr:::::::::FC12214499FCC7BA1CFF6CDC0312384E3A73940B:' && echo "key fingerprint OK"
+ sudo install -m 644 3proxy-release-key.asc /usr/share/keyrings/3proxy.asc
+ sudo tee /etc/apt/sources.list.d/3proxy.sources <<EOF
+ Types: deb
+ URIs: https://3proxy.org/repo/deb
+ Suites: current
+ Components: main
+ Signed-By: /usr/share/keyrings/3proxy.asc
+ EOF
+ sudo apt update && sudo apt install 3proxy
```
- **From source (latest):**
+ RHEL, AlmaLinux, Rocky and CentOS Stream 8–10 use the dnf repository described at https://3proxy.org/repo/. A container image is on Docker Hub as `3proxy/3proxy` (tags `latest`, `1.0.0`, `lts`, `busybox`, `minimal`):
+
```bash
- cd /tmp && git clone https://github.com/3proxy/3proxy.git && cd 3proxy
- make -f Makefile.Linux && make -f Makefile.Linux install
- mkdir -p /etc/3proxy /var/log/3proxy
+ docker run -d --name 3proxy --read-only -p 3128:3128 -p 1080:1080 \
+ -v /srv/3proxy/3proxy.cfg:/etc/3proxy/3proxy.cfg:ro 3proxy/3proxy:1.0.0
```
- **Systemd service** (`/etc/systemd/system/3proxy.service`):
- ```ini
- [Unit]
- Description=3proxy - tiny proxy server
- After=network.target
+ In the container, use a bare `log` line so records go to stdout (`docker logs 3proxy`).
- [Service]
- Type=simple
- ExecStart=/usr/local/bin/3proxy /etc/3proxy/3proxy.cfg
- ExecReload=/bin/kill -HUP $MAINPID
- Restart=on-failure
- LimitNOFILE=65536
+ **What the package installs:**
- [Install]
- WantedBy=multi-user.target
- ```
+ | Path | Purpose |
+ |---|---|
+ | `/etc/3proxy/3proxy.cfg` | Launcher: `chroot /usr/local/3proxy proxy proxy`, then `include /conf/3proxy.cfg`. Leave it alone. |
+ | `/etc/3proxy/conf/3proxy.cfg` | The config to edit (`/etc/3proxy/conf` links to `/usr/local/3proxy/conf`). |
+ | `/etc/3proxy/conf/passwd`, `counters`, `bandlimiters` | Users, traffic quotas and speed limits written by `add3proxyuser`. |
+ | `/var/log/3proxy` | Links to `/usr/local/3proxy/logs`. |
+ Because of the chroot, every path **inside** the editable config is relative to `/usr/local/3proxy`: `/conf/passwd`, `/logs/3proxy.log`, `/count/3proxy.3cf`. The package enables `3proxy.service` and tries to start it, but the packaged config reads `/conf/passwd`, which does not exist until the first `add3proxyuser` call — until then 3proxy exits with a parse error. Manage the service with `systemctl restart 3proxy`; `systemctl reload 3proxy` (sends `SIGUSR1`) re-reads the config of a running service.
+
### Step 2: Basic Configuration
- **Minimal HTTP + SOCKS5 proxy** (`/etc/3proxy/3proxy.cfg`):
- ```
- daemon
- log /var/log/3proxy/3proxy.log D
- logformat "L%t %N %p %E %C:%c %R:%r %O %I %T"
- rotate 30
+ `/etc/3proxy/conf/3proxy.cfg` — authenticated HTTP and SOCKS5 proxy:
+ ```
+ nscache 65536
nserver 1.1.1.1
nserver 8.8.8.8
- nscache 65536
- timeouts 1 5 30 60 180 1800 15 60
- internal 0.0.0.0
- external 0.0.0.0
+ config /conf/3proxy.cfg
+ monitor /conf/3proxy.cfg
- proxy -p3128 # HTTP proxy
- socks -p1080 # SOCKS5 proxy
- ```
+ log /logs/3proxy.log D
+ logformat "L%Y-%m-%d %H:%M:%S %N.%p %E %U %C:%c %R:%r %O %I %T"
+ rotate 30
- **With authentication** (password types: `CL:` cleartext, `CR:` crypt hash, `NT:` NT hash):
- ```
- users admin:CL:strongpassword123
- users user1:CL:password1
+ counter /count/3proxy.3cf
+ users $/conf/passwd
+ include /conf/counters
+ include /conf/bandlimiters
auth strong
+ deny * * 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
+ allow *
proxy -p3128
socks -p1080
```
- ### Step 3: Access Control Lists (ACLs)
+ `monitor` reloads the config within a minute of the file changing. `log` with no file name writes to stdout; `log @3proxy` writes to syslog. `D` rotates daily (the file on disk is `3proxy.log.2026.10.01`) and `rotate 30` keeps 30 files. The `counter` and `include` lines come from the packaged config: they load the quotas and speed limits that `add3proxyuser` writes. Do not add `daemon` under systemd — the unit is `Type=simple`.
- ACL rules are processed top to bottom, first match wins:
+ ### Step 3: Users and Authentication
+
+ ```bash
+ sudo add3proxyuser alice "$ALICE_PROXY_PASSWORD" # hashed entry in /etc/3proxy/conf/passwd
+ sudo add3proxyuser bob "$BOB_PROXY_PASSWORD" 2048 8388608 # + 2048 MB/day quota and an 8 Mbit/s cap
+ sudo systemctl restart 3proxy
```
- users admin:CL:adminpass
- users dev1:CL:devpass
- auth strong
- allow admin # Full access
- allow dev1,dev2 * * 80,443 # Devs: HTTP/HTTPS only
- deny * # Block everything else
+ A `users` line can also be written by hand. Password types: `CL:` cleartext, `CR:` crypt hash (`$3$` BLAKE2b, or `$1$` MD5-crypt when built with OpenSSL), `NT:` NT hash. `3proxy_crypt "$PROXY_SALT" "$ALICE_PROXY_PASSWORD"` prints a ready `CR:$3$…` value. Quote any entry that contains `$` — an unquoted `$` starts a file include:
- proxy -p3128
- socks -p1080
```
-
- **Time-based:** `allow * * * * 1-5 08:00:00-18:00:00` (Mon-Fri work hours)
+ users "alice:CR:$3$k7Qm2x$G47yV9w…" ops:CL:Winter-Harbor-48
+ ```
- **IP-based:** `allow * 192.168.1.0/24` then `deny *`
+ `auth` types: `none` (default — ACLs, limits and parents are **not** applied), `iponly` (ACLs by address, no password), `strong` (username and password), `cache`/`cacheacl` with `authcache`. `auth iponly strong` asks for a password only when the matching rule names a user.
- **Destination filtering:** `deny * * facebook.com,instagram.com *`
+ ### Step 4: Access Control Lists (ACLs)
- ### Step 4: Multi-Port / Multi-Protocol
+ Fields, in order: users, source addresses, targets, target ports, operations, weekdays, time periods. Lists are comma-separated without spaces; `*` means any. Rules are checked top to bottom and the first match wins. An empty list means `allow *`; a non-empty list ends with an implicit `deny *`.
```
- # No-auth proxies on localhost
- auth none
- internal 127.0.0.1
- proxy -p3128
- socks -p1080
+ auth strong
+ # host names, with a wildcard at either end
+ deny * * *facebook.com,*instagram.com
+ # full access for one user
+ allow admin
+ # web ports only
+ allow alice,bob * * 80,443
+ # office LAN, Monday to Friday, working hours
+ allow * 192.168.1.0/24 * * * 1-5 08:00:00-18:00:00
+ ```
- # Authenticated proxies on public interface
+ Operations include `CONNECT`, `BIND`, `UDPASSOC`, `HTTP`, `HTTPS`, `HTTP_GET`, `HTTP_POST` and `FTP`. A host-name rule only matches when the client sends a host name, so pair it with address rules.
+
+ ### Step 5: Several Services with Different Rules
+
+ `flush` empties the access list; without it, rules keep accumulating for every later service.
+
+ ```
+ # LAN clients, no password
+ auth iponly
+ allow * 10.8.0.0/24
+ proxy -p3128 -i10.8.0.1
flush
+
+ # Internet-facing SOCKS5, password required
auth strong
- users admin:CL:password
- internal 0.0.0.0
- proxy -p8080
- socks -p1081
+ allow alice,bob * * 80,443
+ socks -p1080 -i203.0.113.50
```
- **Port forwarding:** `tcppm 2222 10.0.0.5 22` (forward local 2222 to SSH)
+ `-i` sets the listening address for one service and `-e` the outgoing address; the `internal` and `external` commands set them for every service that follows. Port forwarding: `tcppm -i127.0.0.1 2222 10.0.0.5 22` maps local port 2222 to SSH on 10.0.0.5.
- ### Step 5: Proxy Chaining
+ ### Step 6: Parent Proxies (Chaining and Rotation)
+ `parent` extends the `allow` rule directly above it — a `parent` with no preceding `allow` is a startup error. The first argument is a weight from 1 to 1000. Parents whose weights add up to 1000 form one group, and one member is picked at random per new connection. Every further 1000 adds another hop.
+
```
- # Route through upstream proxy
- parent 1000 socks5 upstream-proxy.com 1080 user pass
+ auth strong
- # Load balance across multiple upstreams (weight-based)
- parent 1000 socks5 proxy1.com 1080
- parent 1000 socks5 proxy2.com 1080
+ # Rotation: one hop, chosen at random among three upstreams
+ allow alice
+ parent 334 socks5 198.51.100.11 1080 rotate Upstream-Pass-71
+ parent 333 socks5 198.51.100.12 1080 rotate Upstream-Pass-71
+ parent 333 socks5 198.51.100.13 1080 rotate Upstream-Pass-71
- # Double hop: socks5+ connects through the previous parent
- parent 1000 socks5 hop1.com 1080 user1 pass1
- parent 500 socks5+ hop2.com 1080 user2 pass2
+ # Two-hop chain: SOCKS5 first, then an HTTP CONNECT proxy
+ allow bob
+ parent 1000 socks5 198.51.100.11 1080
+ parent 1000 connect 198.51.100.40 3128
proxy -p3128
- socks -p1080
```
- ### Step 6: Bandwidth & Traffic Control
+ Types: `socks4`, `socks5`, `connect` (HTTP CONNECT), `http`, `tcp`, `extip` (only sets the outgoing address). A trailing `+` (`socks5+`, `connect+`) lets the parent resolve host names; combine it with `fakeresolve`. A trailing `s` (`socks5s`, `https`) connects to the parent over TLS and needs `ssl_client_mode 3`. `parentretries 3` retries a failed parent.
+ ### Step 7: Bandwidth, Connection and Traffic Limits
+
```
- bandlimin 1048576 user1 # Limit user1 to 1 MB/s
- bandlimout 2097152 * # 2 MB/s outbound for all
- connlim 5 * # Max 5 concurrent connections per user
- maxconn 1000 # Total connection limit
+ # simultaneous connections per service started below (default 100)
+ maxconn 1000
+ # alice: 5 parallel connections (period 0); bob: 120 new connections per 60 seconds
+ connlim 5 0 alice
+ connlim 120 60 bob
+ # rates are bits per second: 8 Mbit/s incoming for alice, 2 Mbit/s outgoing shared by everyone
+ bandlimin 8388608 alice
+ bandlimout 2097152 *
- # Traffic accounting with monthly quotas
- counter /var/log/3proxy/traffic.counters
- countin 10737418240 * * * # 10GB monthly incoming per user
- countout 10737418240 * * * # 10GB monthly outgoing per user
+ counter /count/3proxy.3cf
+ # counter 1: 51200 MB per month in both directions; counter 2: 2048 MB incoming per day
+ countall 1 M 51200 alice
+ countin 2 D 2048 bob
```
- ### Step 7: Security Hardening
+ `connlim` takes a rate **and** a period. `countin`/`countout`/`countall` take a counter number (sequential, and unique across the config — `add3proxyuser` numbers the ones it writes to `/conf/counters` from 0), a period (`H`, `D`, `W`, `M`) and a limit in megabytes. One rule that lists several users or a CIDR gives them a shared limit; write one rule per user for individual limits. `maxconn` affects the services started after it; bandwidth limits and counters apply to every service.
- ```
- setgid 65534
- setuid 65534
- internal 10.0.0.1 # Restrict listening interface
- timeouts 1 5 30 60 180 1800 15 60
- connlim 3 *
- bandlimin 524288 *
+ ### Step 8: Security Hardening
- # Block proxy access to private networks
- deny * * 127.0.0.0/8 *
- deny * * 10.0.0.0/8 *
- deny * * 172.16.0.0/12 *
- deny * * 192.168.0.0/16 *
- allow *
```
+ # bind explicitly instead of listening on every interface
+ internal 203.0.113.50
+ external 203.0.113.50
+ auth strong
+ deny * * 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16
+ allow alice,bob * * 80,443
+ socks -p1080
+ ```
- **Firewall:**
+ Restrict the ports at the firewall as well:
+
```bash
- ufw allow from 10.0.0.0/8 to any port 3128 proto tcp
- ufw allow from 10.0.0.0/8 to any port 1080 proto tcp
- ufw deny 3128
- ufw deny 1080
+ sudo ufw allow from 198.51.100.0/24 to any port 1080 proto tcp
+ sudo ufw deny 1080/tcp
```
## Examples
- ### Example 1: Set up an authenticated multi-protocol proxy for a small team
- **User prompt:** "Set up a 3proxy server on our Ubuntu VPS at 203.0.113.50 with HTTP and SOCKS5 proxies. Create accounts for alice and bob with 50GB monthly traffic limits each, restrict them to web ports only, and give me full admin access."
+ ### Example 1: Authenticated HTTP and SOCKS5 proxy for a small team
- The agent will install 3proxy from source, create a systemd service, and generate `/etc/3proxy/3proxy.cfg` with DNS settings, two user accounts (alice and bob) with `auth strong`, ACL rules granting admin full access and restricting alice/bob to ports 80 and 443, bandwidth counters set to 53687091200 bytes (50GB), HTTP proxy on port 3128 and SOCKS5 on port 1080, and proper logging with 30-day rotation.
+ **User prompt:** "Set up 3proxy on our Ubuntu VPS at 203.0.113.50 with HTTP and SOCKS5. Create accounts for alice and bob with 50 GB of traffic a month each, web ports only, and give me (ops) full access."
- ### Example 2: Chain traffic through an upstream SOCKS5 proxy with IP rotation
- **User prompt:** "Configure our 3proxy to route all outgoing traffic through three upstream SOCKS5 proxies for IP rotation. The upstreams are at proxy1.example.com:1080, proxy2.example.com:1080, and proxy3.example.com:1080 with user 'rotate' and password 'r0tate!2025'. Local proxy should listen on port 8080."
+ ```bash
+ sudo apt install 3proxy # after adding the repository from Step 1
+ sudo add3proxyuser ops "$OPS_PROXY_PASSWORD"
+ sudo add3proxyuser alice "$ALICE_PROXY_PASSWORD"
+ sudo add3proxyuser bob "$BOB_PROXY_PASSWORD"
+ ```
- The agent will edit the 3proxy config to define three `parent` directives with equal weights of 1000 each pointing to the upstream SOCKS5 servers with credentials, then configure a local HTTP proxy on port 8080 and SOCKS5 on port 1081, enable logging to track which upstream was used per request, and restart the 3proxy service.
+ In `/etc/3proxy/conf/3proxy.cfg`, keep the `nserver`, `log`, `counter /count/3proxy.3cf` and `users $/conf/passwd` lines and replace everything from `auth strong` down (including `admin -p8080`):
+ ```
+ countall 1 M 51200 alice
+ countall 2 M 51200 bob
+ auth strong
+ deny * * 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
+ allow ops
+ allow alice,bob * * 80,443
+ proxy -p3128 -i203.0.113.50
+ socks -p1080 -i203.0.113.50
+ ```
+
+ ```bash
+ sudo systemctl restart 3proxy
+ curl -x http://alice:"$ALICE_PROXY_PASSWORD"@203.0.113.50:3128 https://ifconfig.me
+ ```
+
+ Result: `curl` prints `203.0.113.50`. A request from alice to any port other than 80 or 443 is refused, and so is all of her traffic once the 51200 MB monthly counter is used up.
+
+ ### Example 2: Rotate outgoing traffic across three upstream SOCKS5 proxies
+
+ **User prompt:** "Route everything from our scraper through three upstream SOCKS5 proxies at 198.51.100.11, .12 and .13 port 1080, user 'rotate', and listen locally on port 8080."
+
+ Remove the packaged service section (from `auth strong` down, including `admin -p8080`), then append the new one. The upstream password is read from the environment:
+
+ ```bash
+ sudo add3proxyuser scraper "$SCRAPER_PROXY_PASSWORD"
+ sudo tee -a /etc/3proxy/conf/3proxy.cfg >/dev/null <<EOF
+ auth strong
+ allow scraper
+ parent 334 socks5 198.51.100.11 1080 rotate ${UPSTREAM_PROXY_PASSWORD}
+ parent 333 socks5 198.51.100.12 1080 rotate ${UPSTREAM_PROXY_PASSWORD}
+ parent 333 socks5 198.51.100.13 1080 rotate ${UPSTREAM_PROXY_PASSWORD}
+ proxy -p8080 -i127.0.0.1
+ EOF
+ sudo systemctl restart 3proxy
+ for i in 1 2 3 4; do curl -s -x http://scraper:"$SCRAPER_PROXY_PASSWORD"@127.0.0.1:8080 https://ifconfig.me; echo; done
+ ```
+
+ Result: the printed address changes between the three upstreams from one connection to the next. With `%R` in `logformat`, each log record shows which upstream served the request.
+
## Guidelines
- - Always use `auth strong` on publicly exposed proxy ports; never run open proxies accessible from the internet
- - Run 3proxy as an unprivileged user with `setuid`/`setgid` and block proxy access to private RFC1918 IP ranges to prevent SSRF attacks
- - Use the `flush` directive to separate configuration blocks with different auth or interface settings; without it, settings accumulate
- - Place deny rules for private networks before the final `allow *` since 3proxy processes ACLs top to bottom with first-match semantics
- - Set `connlim` and `bandlimin` to prevent a single user from exhausting server resources, and enable traffic counters for usage monitoring
- - Back up `/etc/3proxy/3proxy.cfg` before editing since 3proxy has no config validation command and a syntax error will prevent startup
+ - A comment must start the line with `#`. Text after a command is parsed as arguments, and a line that starts with a space is ignored entirely — so never indent directives or append `# notes` to them.
+ - 3proxy has no config-check option. A bad line stops startup with a message such as `Command: 'connlim' wrong number of arguments , line 14`; read it with `journalctl -u 3proxy -n 20` and keep a copy of the working config before editing.
+ - Never expose a service with `auth none`: it is an open proxy, and ACLs, limits and parents are ignored. Use `auth strong` on public addresses and `auth iponly` only for trusted networks.
+ - `strong` authentication sends the password in clear text over plain HTTP and SOCKS5. Reach the proxy through a VPN or SSH tunnel, or use the built-in TLS server (`ssl_serv`, with `ssl_server_cert` and `ssl_server_key`).
+ - The `%E` field of a log record explains a refusal: `1` denied by a `deny` rule, `3` no rule matched, `4`–`8` missing user or wrong password, `10` traffic or connection limit exceeded, `13` connect failed.
+ - Deny loopback and private ranges before any `allow`, otherwise proxy users can reach services on the proxy host and its internal network.
+ - The packaged config also starts the web admin interface (`admin -p8080`). Remove that line or bind it with `-i127.0.0.1`.
+ - Parent weights must add up to a multiple of 1000. Three parents at 1000 each make a three-hop chain, not rotation.
+ - `bandlimin`/`bandlimout` rates are bits per second; multiply bytes per second by 8.
+ - Start the service as root and let the config drop privileges — the packaged launcher does `chroot /usr/local/3proxy proxy proxy`; in a custom config put `setgid` before `setuid`, after the last service on a privileged port.
+ - When you download a release file by hand, check it first: `sha256sum -c SHA256SUMS-x86_64 --ignore-missing`, and `gpg --verify SHA256SUMS-x86_64.asc SHA256SUMS-x86_64` with the project's release key.
+ - 3proxy is not a caching proxy and not a VPN: it does not cache responses or tunnel all of a device's traffic.