proxy-suite-flake
A declarative proxy stack for NixOS. Route this host's traffic through proxies, serve proxies to others, or both, all from one Nix config that runs as systemd services. Also runs on other Linux distributions (system-manager, home-manager) and on Android (Nix-on-Droid).
Important
For study and research only: learning how proxies, tunnels and traffic routing work. No warranty; the authors are not responsible for how it is used.
Note
Much of the code and documentation was written with AI tools, then reviewed and tested on real setups.
Bundles sing-box, XRay, AmneziaWG, zapret-discord-youtube, zapret2, tg-ws-proxy and whitelist-bypass; see their repositories for licenses and docs. Inspired by Throne (formerly NekoRay), 3x-ui and similar projects.
Features
- Local SOCKS5/HTTP proxy on
127.0.0.1:1080, on sing-box, XRay, or both - System-wide TUN or TProxy mode, on demand or at boot
- Kill switch: nothing leaks while a global tunnel restarts or after it fails
- Per-app routing:
proxy-ctl apps run <profile> -- <cmd>, or packages wrapped to always use the proxy - Outbounds from links, raw JSON or subscriptions, picked by hand or by latency
- vless (REALITY, TLS), vmess, trojan, shadowsocks, hysteria2, socks, http; TUIC, AnyTLS and NaïveProxy on sing-box; XHTTP and ECH on XRay
- Proxy chains: any outbound can connect through another
- autoProxy: finds an exit that reaches each blocked site and routes it there
- zapret DPI bypass, including zapret2, which learns blocked sites on its own
- AmneziaWG 1.x–3.x from
.conf,vpn://or Nix - Cloudflare WARP, Tor (with bridges and an onion service), an SSH tunnel and a Telegram proxy
- Tunnels through video-call servers, to get past mobile internet whitelists
- Server inbounds (XRay protocols, hysteria2, AmneziaWG) with share links, QR codes, subscriptions and traffic stats
- A desktop GUI with a tray icon, the
proxy-ctlCLI and theproxy-tuiterminal UI
Setup
inputs.proxy-suite.url = "github:FUFSoB/proxy-suite-flake";
modules = [ inputs.proxy-suite.nixosModules.default ];
A starter config:
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
backend = "sing-box"; # or "xray", "hybrid"
# `url` ends up in the Nix store; use `urlFile` for secrets.
outbounds = [ { tag = "nl-vps"; url = "hy2://password@example.com:443?sni=example.com"; } ];
subscriptions = [ { tag = "main-sub"; urlFile = "/run/secrets/sub-url"; } ];
selection = "urltest"; # pick the fastest; default "first"
tproxy.enable = true;
tun.enable = true;
};
perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
tun.enable = true;
tproxy.enable = true;
zapret.enable = true;
};
zapret.enable = true;
sshProxy = {
enable = true;
server = {
user = "root";
host = "ssh.example.com";
};
identityFile = "/run/secrets/proxy-suite-ssh-key";
hostKeyFile = "/run/secrets/proxy-suite-ssh-known-hosts";
};
# Only one global tunnel (AWG, TUN or TProxy) runs at a time.
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home-amneziawg.conf";
profiles.work.vpnFile = "/run/secrets/work-amnezia.vpn";
# Or use a profile as an outbound, tagged "de":
profiles.de = {
asOutbound = "interface"; # or "userspace" (no root), "singBox" (plain WireGuard)
configFile = "/run/secrets/de-amneziawg.conf";
};
};
warp = {
enable = true;
asOutbound = "singBox"; # outbound tagged "warp"
# asAmneziaWg = true; # or a global profile: proxy-ctl awg on warp
};
# Outbound tagged "tor"; .onion names always go there.
tor = {
enable = true;
asOutbound = true;
# bridges.file = "/run/secrets/tor-bridges";
# upstream = "proxy"; # reach Tor through the proxy
};
tgWsProxy = {
enable = true;
secretFile = "/run/secrets/tg-ws-proxy-secret";
};
# Tunnel through a video call. A creator runs on a free server and logs the call link;
# the joiner here is an outbound tagged "wl".
whitelistBypass = {
enable = true;
creators.phone = { platform = "wbstream"; cookiesFile = "/run/secrets/wb-cookies.json"; };
# joiners.wl = { platform = "wbstream"; linkFile = "/run/secrets/wb-link"; };
};
gui.enable = true;
};
Docs
- Usage guides: common setups, step by step, and complete examples.
- Options reference: every option. Regenerate it and the help below with
nix run .#update-docs.
proxy-ctl help
Usage: proxy-ctl <group> [verb] [args]
A group alone shows its status or list.
Groups with on|off also take toggle and restart.
Changes and secrets need root or the userControl group.
status [--json] services and routing mode (--tray: deprecated)
restart restart running services
logs [unit...] follow logs (default: all proxy-suite units); in a
terminal, in lnav: scroll back, G follows, q quits
where <domain> how a domain is routed right now
proxy [status|on|off] local proxy
proxy outbounds [list] outbounds, their source, and the current pick
proxy outbounds add [tag] <url|json|-> [--detour <tag>]
add an outbound from a link or JSON (-: stdin);
--detour: connect through another outbound
proxy outbounds add [tag] <vpn://…|file.conf|-> [--container <name>]
add an AmneziaWG outbound (runs in wireproxy)
proxy outbounds chain <tag> <through-tag> [new tag]
add a copy of an outbound that connects through another
proxy outbounds rm <tag> remove a runtime outbound
proxy outbounds disable|enable <tag> exclude from automatic use (selection, autoProxy), or undo
proxy outbounds test [tag...] [--ping] [--delay] [--download]
test ping, delay, download speed (default: ping, delay)
proxy outbounds link <tag> [--qr|--json|--config]
its link, QR code, JSON, or client config
proxy pin [tag] [--in <group>] always use this outbound (no tag: pick from a menu);
--in: hold a group on one of its members
proxy unpin [--in <group>] go back to automatic selection
proxy groups [list] outbound groups, their members, and what each uses
proxy groups add <tag> [member...] [--sub <sub>]... [--match <pattern>]...
[--strategy failover|urltest|selector] [--no-failback] [--interval <d>]
add a group (failover by default)
proxy groups rm <tag> remove a group added with groups add
proxy groups members <tag> add|rm <member...>
proxy groups strategy <tag> failover|urltest|selector
proxy priority [list] the top level in the order it is picked in
proxy priority <tag> <n>|up|down|--clear
lower goes first; up/down renumbers the top level
proxy mode [default|whitelist|blacklist|all-proxy|all-bypass]
show or override the routing mode
proxy subs [list|update] subscriptions; update refetches them
proxy subs add [tag] <url> add a subscription (no tag: named after its host)
proxy subs rm <tag> remove a runtime subscription
proxy subs link <tag> [--qr] its URL
proxy rulesets [list|update] rule sets and when they were fetched; update refetches
proxy config [--raw] client config to use elsewhere; --raw: as running
proxy tun [status|on|off] global TUN mode
proxy tproxy [status|on|off] global TProxy mode
proxy auto [list] what autoProxy routed, and through which exit
proxy auto probe <domain>[/path] [--json] [--keep-going] [--exits a,b | --via tag]
find an exit that reaches a domain
proxy auto learn <domain> probe now, and route it if an exit works
proxy auto forget <domain> forget it (direct until learned again)
proxy auto relearn <domain> forget it and probe again now
proxy auto clear forget everything learned
proxy auto queue [count] destinations waiting to be probed
zapret [status|on|off] DPI bypass
zapret auto [list] sites zapret2 learned as blocked
zapret auto add|forget|exclude <domain>
treat a site as blocked, forget it, or never touch it
zapret auto unpin|include <domain> undo add or exclude
zapret auto clear forget learned sites and strategies
zapret cutoff [status] networks cut off at 16 KB, and names that pass
zapret cutoff probe probe again now
awg [list] AmneziaWG profiles
awg on <profile> | off [profile] | toggle [profile] | restart [profile]
awg add [name] <vpn://…|file.conf|-> [--container <name>]
add a global profile (-: stdin)
awg rm <profile> remove a profile added with awg add
killswitch [status|on|off] block traffic outside the global tunnel;
stays on until turned off here or with the tunnel
ssh [status|on|off] SSH tunnel
warp [status|on|off] [device] WARP tunnel (every device, or the one named)
tor [status|on|off] Tor
tor newnym new circuits for new connections
tg [status|on|off] Telegram proxy
wl [list] whitelist-bypass creators and joiners
wl link <creator> [--qr] the call link for its joiner
wl auth <creator> [file|-] replace its login: cookies, or prompt (DION, Bitrix)
wl join <joiner> <link|-> set the call to join
wl new <creator> start a new call
wl on|off|toggle|restart [name] one creator or joiner, or all
apps [list] per-app routing profiles
apps run <profile> -- <cmd> [args] run a command through a profile
apps run --via <outbound> -- <cmd> run a command through one outbound
(--route tun|tproxy picks the method)
apps add <name> [--route r] [--via o] add a profile without a rebuild
apps rm <name> remove one added that way
inbounds [list] server inbounds
inbounds link <tag> [user] [--onion|--variant=<name>] [--qr|--json]
share link or client JSON; --onion: via the onion
service; --variant: one of the listener's shareVariants
inbounds link <tag> [user] --config [--qr]
AmneziaWG client .conf or its QR code
inbounds link <tag> --server-json the server's inbound JSON
inbounds sub [user] [--qr] subscription users, or one user's URL
inbounds stats [days] [--by user|inbound|outbound]
traffic by user, listener or exit
inbounds users [list] users: order, serverSource address, listeners
(the rest below needs inbounds.runtime)
inbounds users add <name> [--order N] [--listener <tag>]...
add a user at runtime, with generated secrets
inbounds users rm <name> remove a runtime user
inbounds users order <name> <N> a runtime user's order (serverSource number)
inbounds bind|unbind <user> <tag> put a user on a listener, or take it off
(a runtime user, or a runtime listener)
inbounds add <tag> <type> [--port N] [--via V] [--transport T] [--path P] [--host H]
[--reality SNI[,SNI]] [--tls <cert>] [--alpn a,b] [--flow vision] [--method M]
[--listen A] [--user U]... [more: see inbounds add --help]
add a listener at runtime
inbounds add <tag> <file.json|-> add one from JSON shaped like inbounds.listeners.<tag>
inbounds rm <tag> remove a runtime listener
inbounds show <tag> a runtime listener's JSON
inbounds online who is online, and when others were last seen