- Go 36.9%
- HTML 21.3%
- Shell 21.1%
- Nix 20.7%
Track the signals needed to tell a sick host from a sick path alongside bandwidth: SYN and lost TCP retransmits, NIC-level errors and drops, conntrack occupancy, handshake failures (backlog drops, embryonic RSTs), and a periodic uplink probe as a control. Surface them in a new dashboard section and write one health line to the journal every five minutes, so the numbers outlive the page's 24-hour window. |
||
|---|---|---|
| dashboard | ||
| hosts/nixproxy | ||
| scripts | ||
| secrets | ||
| .gitignore | ||
| .sops.yaml | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
linode-nix-vless-proxy
A small NixOS (26.05) VPS on Akamai/Linode running an Xray VLESS+Reality server on :443, as a personal censorship-circumvention proxy. It's meant to be cheap (a 1 GB Nanode, $5/mo), reproducible from one flake, and safe to keep in a public repo: every secret and every host-specific detail is encrypted with sops + age.
Linode has no first-party NixOS image, so the install goes through a custom installer disk booted in rescue mode, following Akamai's "Install and Configure NixOS on a Linode" guide with adjusted sizes.
Layout
| Path | What it is |
|---|---|
flake.nix, hosts/nixproxy/ |
The NixOS config. xray.nix is the proxy. |
secrets/xray.yaml |
UUID, Reality private key, short id. Encrypted to you and the server (sops-nix decrypts it on the host). |
secrets/server.yaml |
Server IP, pinned SSH host key, SSH private key. Encrypted to you only; the server can't read it. |
dashboard/ |
A small Go service (stdlib only) and NixOS module that serves a stats page on loopback. See below. |
scripts/ |
Provisioning, ssh, client config and a connectivity test. They read secrets/server.yaml, so nothing host-specific is hard-coded. |
client/ |
Generated client material. Gitignored. |
Disk layout on a Nanode (25600 MB):
| Disk | Size | Role |
|---|---|---|
| installer | 1792 MB | NixOS minimal ISO written with dd |
| swap | 512 MB | swap |
| nixos | 23296 MB | root filesystem |
Two config profiles: installer (direct-disk, root /dev/sdc) and boot (GRUB 2, root
/dev/sda), with all Linode boot helpers disabled.
Setting up your own
You need sops, age, linode-cli (with a token) and ssh. Nix isn't needed locally.
-
Make an age key if you don't have one:
age-keygen -o ~/Library/Application\ Support/sops/age/keys.txt(on Linux:~/.config/sops/age/keys.txt). Put the public key in.sops.yamlasadmin. -
Run
scripts/01-provision.sh, then create the two profiles it describes, boot the installer and install the flake. Take the server's age key from its SSH host key (ssh-keyscan <server-ip> | ssh-to-age) and add it to.sops.yamlasnixproxy. -
Create the secrets (
sops secrets/xray.yaml,sops secrets/server.yaml):# secrets/xray.yaml (xray uuid / xray x25519 / openssl rand -hex 8) xray: uuid: ... private_key: ... short_id: ... # secrets/server.yaml server: ip: <server-ip> known_hosts: "<server-ip> ssh-ed25519 AAAA..." ssh_key: | -----BEGIN OPENSSH PRIVATE KEY----- ... -
Put the matching public key in
hosts/nixproxy/configuration.nixunderopenssh.authorizedKeys.keys, and change thedougusername if you like. -
scripts/ssh.shnow connects with no further setup.scripts/client-config.shbuilds the client JSON and avless://share link from the files inclient/(uuid.txt,reality-public-key.txt,short-id.txt).
Findings: non-443 ports and a blocked IP
The first server (Toronto) was unusable on :443 from one China WiFi: nc timed out 5/5 while :22
connected 5/5, and a packet capture showed the :443 SYNs never arrived. To get around that the same
Reality inbound was opened on 8443 and 2053, which worked, at about 10 Mbit/s down.
It didn't last. The tunnel ran for 10-20 minutes, then slowed and eventually passed nothing. A capture on the server showed a hard cut rather than a slowdown: every flow from the client's IP stopped in the same second, the server kept retransmitting into the void, and a client on another network (a HK eSIM) connected to the same port fine two minutes later. A later probe showed that every port, including SSH, was unreachable from that WiFi, with the client's SYNs arriving and the server's replies never getting back. So the whole IP was being blocked, not one port. Xray warns that Reality on non-443 ports may get an IP blocked, and that fits the timeline, though we can't prove it.
Rerolling to a new IP (see below) and listening on 443 only did not help either: from that same WiFi :443 to the new IP was dropped while :22 connected, the same filtering as on day one. That node was deleted and the original server is the one in use. So the filtering looks tied to the port and path rather than to one IP, and a different protocol alone won't fix it.
Rerolling the IP
Cloning is much faster than reinstalling, and the clone keeps the NixOS install, the sops keys and the SSH host key, so nothing needs re-encrypting.
linode-cli linodes shutdown <id>, thenlinode-cli linodes clone <id> --region <region> --type g6-nanode-1. A cross-region clone of the 25 GB disk took about 50 minutes; the progress sits at 97-99% for a long time.- Boot the clone with its
bootconfig profile. - Check the new host presents the same SSH host key, then update
ip,known_hostsandip6insecrets/server.yaml(sops set). - Rebuild if the config changed, and restart xray explicitly. The port list lives in the rendered secret JSON, so NixOS won't restart the unit on its own.
- Regenerate the client link with
scripts/client-config.sh, then delete the old Linode.
Stats dashboard
dashboard/ builds a read-only stats page: bandwidth served, connected clients, open connections,
and a reliability/health section — TCP retransmit rate (including SYN and lost retransmits), timeouts,
NIC-level errors and drops, conntrack occupancy, handshake failures (backlog drops, embryonic RSTs),
and an uplink probe to a fixed always-on host. The probe is the control: a clean probe alongside
spiking retransmits means the loss is on the client path, not the box. It samples kernel counters from
/proc every 30 seconds, so it needs no Xray API and no change to the Xray config, and keeps 24 hours
of history. It uses about 8 MB of RAM and never exposes client addresses, only counts.
It listens on 127.0.0.1:31443 and no firewall port is opened, so a web server never shares an IP
with the proxy. View it through an SSH tunnel:
scripts/ssh.sh -L 31443:127.0.0.1:31443 -N
then open http://localhost:31443. History is kept in the service's state directory and survives
restarts and reboots.
Every five minutes the service also writes one health ... line to the journal — retransmit rate,
SYN/lost retransmits, timeouts, NIC errors and drops, conntrack occupancy, and the probe result — so
the numbers outlive the page's 24-hour window:
scripts/ssh.sh 'journalctl -u proxystats | grep health'
Bandwidth is read from the interface counters, and a proxy sends every byte across the interface twice, so the "served" figures are half the interface total. They also include a little non-proxy traffic (SSH, Nix downloads). Exact per-inbound byte counts would need Xray's stats API, which is deliberately left disabled.
Deploying changes
The flake lives on the server at ~/nixproxy (no local nix). Sync only the files you changed,
since the server's flake.lock is the source of truth (it carries sops-nix); pull it back with
rsync after a build. Then:
scripts/ssh.sh 'cd nixproxy && sudo nixos-rebuild switch --flake .#nixproxy'
scripts/ssh.sh 'sudo systemctl restart xray'
The explicit restart is needed when only the rendered secret JSON changes, because the unit itself
is unchanged and NixOS won't restart it. nixos-rebuild build first is a safe way to check a
change evaluates.
Limitations and things to revisit
- Encrypted secrets in a public repo are permanent. Anyone can copy
secrets/*.yamland the history forever, so their safety rests entirely on your age private key. Back it up, and if it ever leaks, rotate the Xray UUID/keys and the SSH key, not just the age key. - The IP isn't a secret, only less casual. It's in every client's share link and visible to anyone on the path. Keeping it out of the repo just stops drive-by scanning from the README.
- 1 GB is tight for rebuilds. The running system uses ~280 MB, but the live installer and flake evaluation together thrashed a 1 GB machine during the original install. If a rebuild hangs, add a swapfile or resize up for the rebuild (billing is hourly).
- Consider a domain for the client address so a blocked IP can be rerolled by changing one A record. Never use your own domain as the Reality SNI/dest.
- The SSH key was a bootstrap key. Once you pick a permanent one, remove the bootstrap key from the
config and drop
security.sudo.wheelNeedsPassword = falsewith it.