4.5 KiB
Run your own server
Accept proxy clients on a VPS, and hand out share links, QR codes and subscriptions for them. The listeners run on XRay, and AmneziaWG listeners run on AmneziaWG.
A fresh VPS: the installer
If your provider lets you boot a custom ISO, build the installer:
nix build github:FUFSoB/proxy-suite-flake#installer-iso
The image is result/iso/proxy-suite-installer-<build time>-<commit>-<system>.iso. Boot
the VPS from it. The console installer asks for the public IP, users, an optional
domain, whether to run the QEMU guest agent (so the VPS panel sees the server's state)
and the disk to erase, then installs NixOS with nixosModules.server: VLESS
REALITY, TLS and WS listeners, ACME certificates and SSH, with fish as the login shell
and vim (nano stays the default editor), htop, tmux, jq, mtr, iftop, dig and ncdu
(services.proxy-suite-server.tools).
It installs the proxy-suite source the ISO carries: /etc/nixos follows this repository
on GitHub when the ISO's commit is there, and holds a copy otherwise. The disk is laid out by disko
(services.proxy-suite-server.disko): btrfs with compress=zstd:3, subvolumes @ on /,
@nix, @varlog on /var/log and @home, and a 2G swap file in @swap. After the reboot, log in
and run:
proxy-ctl inbounds link vless-reality --qr
An existing NixOS host
services.proxy-suite = {
enable = true;
inbounds = {
enable = true;
serverAddress = "vpn.example.com"; # null: this host's public IPv4
routing.via = "direct"; # clients exit straight from this host
listeners = {
vless-reality = {
type = "vless";
port = 443;
flow = "xtls-rprx-vision";
users = [
{ name = "phone"; uuidFile = "/run/secrets/uuid-phone"; }
{ name = "laptop"; uuidFile = "/run/secrets/uuid-laptop"; }
];
reality = {
enable = true;
serverNames = [ "www.microsoft.com" ];
privateKeyFile = "/run/secrets/reality-private-key";
publicKey = "jNXH…"; # both keys from `xray x25519`
shortIds = [ "0123abcd" ];
};
};
# Keys for the server and each user are generated on first start.
awg = {
type = "amneziawg";
port = 51820;
users = [ { name = "phone"; } ];
};
};
};
};
Store the secrets with your secrets tool (see Keep secrets out of the Nix store). To make them:
uuidgen # one UUID per user
nix run nixpkgs#xray -- x25519 # the private key for the file, the public key for the config
The firewall opens the listener ports on its own. Other protocols (trojan, shadowsocks,
hysteria2, vmess, …) and transports (ws, grpc, xhttp) are set per listener; see
inbounds.listeners.
Share access
proxy-ctl inbounds # listeners
proxy-ctl inbounds link vless-reality phone --qr # link as a QR code for the phone
proxy-ctl inbounds link awg phone --config # AmneziaWG .conf
proxy-ctl inbounds stats # traffic per user
proxy-ctl inbounds online # who is connected
Subscriptions give each user one URL with their links from every listener, so clients pick up changes on their own. Enable them and serve the directory with a web server:
services.proxy-suite.inbounds.subscriptions = {
enable = true;
baseUrl = "https://vpn.example.com/sub";
};
services.nginx.virtualHosts."vpn.example.com".locations."/sub/".alias =
"/run/proxy-suite-inbounds/subscriptions/";
Then proxy-ctl inbounds sub phone --qr prints that user's subscription.
Good to know
- Clients cannot reach this host's LAN or Russian sites by default
(
inbounds.routing.blockPrivate,blockRu). - With
routing.via = "proxy"(the default), client traffic goes through this host's own proxy instead, following its routing. That needsproxy.enable. A listener can also exit through one outbound withvia = "<tag>". - For clients that cannot reach the server at all,
tor.onionServiceserves the listeners over Tor too.