docs: improve the wording, add targeted examples
This commit is contained in:
61 files changed
+3422
-5861
No files matched your search
@@ -0,0 +1,76 @@
|
||||
# Use an AmneziaWG config
|
||||
|
||||
Bring the AmneziaWG config from your provider or your own server, either as a `.conf` file or
|
||||
as an Amnezia app `vpn://` export. AmneziaWG 1.x to 3.x are supported. Each profile can run
|
||||
in one of two ways:
|
||||
|
||||
- **as a global VPN**: all traffic goes through it, like `wg-quick up`;
|
||||
- **as an outbound**: the proxy sends only what your routing picks through it.
|
||||
|
||||
## As a global VPN
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
amneziaWg = {
|
||||
enable = true;
|
||||
profiles.home.configFile = "/run/secrets/home-awg.conf";
|
||||
profiles.work = {
|
||||
vpnFile = "/run/secrets/work-amnezia.vpn";
|
||||
autostart = true; # at most one profile
|
||||
};
|
||||
};
|
||||
killSwitch.enable = true; # optional: no leaks while the tunnel is down
|
||||
};
|
||||
```
|
||||
|
||||
```sh
|
||||
proxy-ctl awg # profiles and which one is up
|
||||
proxy-ctl awg on home # switches from any other global tunnel
|
||||
proxy-ctl awg off
|
||||
```
|
||||
|
||||
Only one global tunnel runs at a time: an AmneziaWG profile, TUN or TProxy. Starting one
|
||||
stops the others.
|
||||
|
||||
## As an outbound
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy.enable = true;
|
||||
amneziaWg = {
|
||||
enable = true;
|
||||
profiles.de = {
|
||||
configFile = "/run/secrets/de-awg.conf";
|
||||
asOutbound = "interface";
|
||||
};
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
The outbound is tagged with the profile's name (`de` here). It always runs, and leaves the
|
||||
host's routes and DNS alone. Use it like any other outbound: for selection, in
|
||||
[routing rules](./routing.md), or as a hop in a [chain](./chains.md).
|
||||
|
||||
| `asOutbound` | Obfuscation | Needs root | Notes |
|
||||
|---|---|---|---|
|
||||
| `"interface"` | yes | yes | A real AmneziaWG interface with no routes. |
|
||||
| `"userspace"` | yes | no | Runs in wireproxy. The only mode on home-manager and Nix-on-Droid. |
|
||||
| `"singBox"` | no | no | Plain WireGuard inside sing-box. For servers without obfuscation, such as WARP. |
|
||||
|
||||
## Good to know
|
||||
|
||||
- A profile that stops getting handshake replies moves to a new source port on its own.
|
||||
`settings.listenPort` pins the port and turns this off.
|
||||
- If the server's address is blocked, `profiles.<name>.endpoint` replaces it without
|
||||
editing the file.
|
||||
- Imported configs cannot run `PostUp` and other hooks unless you set `allowConfigHooks`.
|
||||
- The profile can also be written in Nix instead of a file, with `profiles.<name>.settings`.
|
||||
- To host an AmneziaWG server, see [Run your own server](./server.md).
|
||||
|
||||
## See also
|
||||
|
||||
- [`amneziaWg.profiles`](../options/amneziaWg.md#services-proxy-suite-amneziawg-profiles)
|
||||
- [`asOutbound`](../options/amneziaWg.md#services-proxy-suite-amneziawg-profiles-name-asoutbound)
|
||||
- [`settings`](../options/amneziaWg.md#services-proxy-suite-amneziawg-profiles-name-settings)
|
||||
@@ -0,0 +1,95 @@
|
||||
# Chain proxies and add exits
|
||||
|
||||
Two things are covered here: reaching a server through another one (a chain), and adding
|
||||
built-in exits (WARP, Tor, an SSH tunnel) for your routing to use.
|
||||
|
||||
## Chains
|
||||
|
||||
Set `detour` to make an outbound connect through another one. This helps when your
|
||||
network cannot reach a server directly but can reach a hop that can. It also hides the
|
||||
final server's address from your ISP.
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [
|
||||
{ tag = "hop"; urlFile = "/run/secrets/hop-url"; }
|
||||
{ tag = "de-vps"; urlFile = "/run/secrets/de-vps-url"; detour = "hop"; }
|
||||
];
|
||||
selectionExclude = [ "hop" ]; # never picked as the exit on its own
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Any outbound can be a hop, including subscription entries, WARP, the SSH tunnel and
|
||||
AmneziaWG outbounds. A subscription's `detour` applies to every entry in it. On the hybrid
|
||||
backend, an XRay outbound can only chain through another XRay outbound.
|
||||
|
||||
At runtime:
|
||||
|
||||
```sh
|
||||
proxy-ctl proxy outbounds chain de-vps hop de-via-hop # a chained copy of de-vps
|
||||
proxy-ctl proxy outbounds add 'vless://…' --detour hop # a new outbound behind hop
|
||||
```
|
||||
|
||||
## Extra exits
|
||||
|
||||
Each of these adds an outbound with a fixed tag. Route sites to it with
|
||||
[routing rules](./routing.md), or use it as a hop.
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
routing.rules = [
|
||||
{ domains = [ "chatgpt.com" "openai.com" ]; outbound = "warp"; }
|
||||
{ domains = [ "check.torproject.org" ]; outbound = "tor"; }
|
||||
];
|
||||
};
|
||||
|
||||
# Tagged "warp". Registers a free WARP device on first start.
|
||||
warp = {
|
||||
enable = true;
|
||||
asOutbound = "singBox";
|
||||
};
|
||||
|
||||
# Tagged "tor". .onion names always go to it.
|
||||
tor = {
|
||||
enable = true;
|
||||
asOutbound = true;
|
||||
};
|
||||
|
||||
# Tagged "ssh-proxy".
|
||||
sshProxy = {
|
||||
enable = true;
|
||||
asOutbound = true;
|
||||
server = { user = "me"; host = "ssh.example.com"; };
|
||||
identityFile = "/run/secrets/ssh-key";
|
||||
hostKeyFile = "/run/secrets/ssh-known-hosts"; # from ssh-keyscan
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
| Exit | Good to know |
|
||||
|---|---|
|
||||
| WARP | Registering accepts Cloudflare's terms. If the Cloudflare API is blocked, set `warp.generatorUrl`, or `warp.configFile` with a profile made elsewhere. If the endpoint is blocked, try `warp.endpoint`. |
|
||||
| Tor | Selection and autoProxy skip it unless it is the only outbound. Where Tor is blocked, add `tor.bridges.lines`, or reach Tor through the proxy with `tor.upstream = "proxy"`. |
|
||||
| SSH | Needs the server's host keys on sing-box (`hostKeyFile` or `hostKey`). Any SSH server that allows TCP forwarding works, with nothing to install on it. |
|
||||
|
||||
## Good to know
|
||||
|
||||
- `proxy.selectionExclude` keeps hops and special exits out of automatic selection. You can
|
||||
still pin them.
|
||||
- autoProxy tries your exits, WARP included, for each blocked site and keeps the first one
|
||||
that works.
|
||||
- WARP can also run as a global VPN instead, through AmneziaWG: `warp.asAmneziaWg`.
|
||||
|
||||
## See also
|
||||
|
||||
- [`detour`](../options/proxy.md#services-proxy-suite-proxy-outbounds-detour)
|
||||
- [`proxy.selectionExclude`](../options/proxy.md#services-proxy-suite-proxy-selectionexclude)
|
||||
- [WARP](../options/warp.md), [Tor](../options/tor.md), [SSH](../options/sshProxy.md)
|
||||
@@ -0,0 +1,68 @@
|
||||
# Connect through a proxy
|
||||
|
||||
Run a local proxy on `127.0.0.1:1080` that forwards traffic through your server or
|
||||
subscription.
|
||||
|
||||
## Config
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
subscriptions = [ { tag = "provider"; urlFile = "/run/secrets/provider-sub-url"; } ];
|
||||
selection = "urltest";
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
- `outbounds` takes proxy links (`vless://`, `hy2://`, `trojan://`, `ss://`, …), one per
|
||||
entry. Put each link in a file; see [Keep secrets out of the Nix store](./secrets.md).
|
||||
- `subscriptions` fetches a list of links from a URL and refreshes it daily. Its entries are
|
||||
tagged with the subscription's tag as a prefix.
|
||||
- `selection` picks which outbound to use: `"first"` (the default), `"urltest"` (the
|
||||
fastest) or `"selector"` (you pick).
|
||||
|
||||
You only need one outbound or subscription. With neither, the proxy waits until you add one
|
||||
with `proxy-ctl proxy outbounds add`.
|
||||
|
||||
## Use it
|
||||
|
||||
Point apps at `127.0.0.1:1080`. The port speaks both SOCKS5 and HTTP. Many apps follow the
|
||||
usual variables:
|
||||
|
||||
```sh
|
||||
export all_proxy=socks5h://127.0.0.1:1080
|
||||
export https_proxy=http://127.0.0.1:1080
|
||||
```
|
||||
|
||||
To route apps without setting them up, see [Route the whole machine](./system-wide.md) or
|
||||
[Route a single app](./per-app.md).
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
proxy-ctl status # what is running
|
||||
proxy-ctl proxy outbounds # outbounds, and which one is in use
|
||||
proxy-ctl proxy outbounds test # ping and delay of each one
|
||||
proxy-ctl proxy pin my-vps # always use this one
|
||||
proxy-ctl proxy unpin # back to automatic selection
|
||||
proxy-ctl proxy outbounds add 'vless://…' # add one at runtime, no rebuild
|
||||
proxy-ctl proxy subs update # refetch subscriptions now
|
||||
```
|
||||
|
||||
## Good to know
|
||||
|
||||
- `proxy.backend` picks the engine: sing-box (the default), XRay, or `"hybrid"`, which runs
|
||||
sing-box and hands XHTTP and ECH links to XRay.
|
||||
- `urltest` tests each outbound by fetching `proxy.urlTest.url`. Set it to a site that is
|
||||
blocked where you are, so an outbound only passes if it really gets around the block.
|
||||
- Set `proxy.listener.auth` before exposing the port with `listener.address = "0.0.0.0"`.
|
||||
|
||||
## See also
|
||||
|
||||
- [`proxy.outbounds`](../options/proxy.md#services-proxy-suite-proxy-outbounds)
|
||||
- [`proxy.subscriptions`](../options/proxy.md#services-proxy-suite-proxy-subscriptions)
|
||||
- [`proxy.selection`](../options/proxy.md#services-proxy-suite-proxy-selection)
|
||||
- [`proxy.backend`](../options/proxy.md#services-proxy-suite-proxy-backend)
|
||||
@@ -0,0 +1,75 @@
|
||||
# Control it day to day
|
||||
|
||||
Once the config is built, you rarely need to rebuild: most switches happen at runtime,
|
||||
through one of three front ends.
|
||||
|
||||
- **`proxy-ctl`**: the command line. `proxy-ctl help` lists everything, and shell completion
|
||||
is included.
|
||||
- **`proxy-tui`**: a terminal UI with the same controls. It works over SSH too. On by default.
|
||||
- **The desktop app** (`gui.enable`): the same again, with a tray icon. It starts with your
|
||||
graphical session.
|
||||
|
||||
The TUI and the app run `proxy-ctl` underneath, so they can do exactly what it can.
|
||||
|
||||
## Without sudo
|
||||
|
||||
Reading status needs no privileges. Changing things does, unless you use `userControl`:
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
};
|
||||
gui.enable = true;
|
||||
userControl = {
|
||||
enable = true;
|
||||
scopes = [ "services" "routing" "outbounds" "perApp" ];
|
||||
};
|
||||
};
|
||||
users.users.alice.extraGroups = [ "proxy-suite" ];
|
||||
```
|
||||
|
||||
Members of the group get the listed scopes. An empty `scopes` list grants all of them:
|
||||
|
||||
| Scope | Allows |
|
||||
|---|---|
|
||||
| `services` | turning services on, off and restarting them |
|
||||
| `routing` | `proxy pin`, `proxy unpin`, `proxy mode` |
|
||||
| `outbounds` | adding, removing, enabling and disabling outbounds and subscriptions |
|
||||
| `perApp` | `apps run` with `tun`, `tproxy` and `zapret` profiles |
|
||||
| `secrets` | reading share links, subscription URLs and running configs |
|
||||
| `autoProxy`, `zapret`, `stats`, `whitelistBypass` | the matching `proxy-ctl` groups |
|
||||
|
||||
Log out and back in after joining the group. Without `userControl`, a change asks for an
|
||||
admin password, or you run `proxy-ctl` with sudo.
|
||||
|
||||
## Runtime changes and the Nix config
|
||||
|
||||
| Change | Lasts |
|
||||
|---|---|
|
||||
| `proxy outbounds add`, `proxy subs add` | until removed with `rm`; kept across reboots |
|
||||
| `proxy outbounds disable` | until `enable`; works on outbounds from Nix too |
|
||||
| `proxy pin` | until `unpin`; kept across reboots |
|
||||
| `proxy mode` | until the next reboot |
|
||||
| `… on` / `… off` | until the next reboot; boot state comes from the config |
|
||||
|
||||
Outbounds from the Nix config cannot be removed at runtime, only disabled.
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
proxy-ctl status # everything at a glance
|
||||
proxy-ctl status --json # the same, for scripts
|
||||
proxy-ctl logs # follow the logs of every proxy-suite service
|
||||
proxy-ctl restart # restart what is running
|
||||
proxy-ctl where example.com
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [`userControl.scopes`](../options/userControl.md#services-proxy-suite-usercontrol-scopes)
|
||||
- [`gui.enable`](../options/gui.md#services-proxy-suite-gui-enable)
|
||||
- [`tui.enable`](../options/tui.md#services-proxy-suite-tui-enable)
|
||||
- [The full `proxy-ctl help`](../../README.md), at the end of the README
|
||||
@@ -0,0 +1,19 @@
|
||||
# Usage guides
|
||||
|
||||
Short guides for common setups. Each one has a minimal config, the commands you will use,
|
||||
and links into the [options reference](../options/index.md) for the details.
|
||||
|
||||
| Guide | When to read it |
|
||||
|---|---|
|
||||
| [Connect through a proxy](./client-basics.md) | You have a proxy link or a subscription |
|
||||
| [Route the whole machine](./system-wide.md) | Every app should use the proxy, not only those set to it |
|
||||
| [Choose what goes through the proxy](./routing.md) | Only blocked sites through the proxy, or everything but some |
|
||||
| [Route a single app](./per-app.md) | Only some apps should use the proxy |
|
||||
| [Unblock sites without a server](./zapret.md) | YouTube, Discord or other sites are slowed or blocked by DPI |
|
||||
| [Run your own server](./server.md) | You have a VPS and want to connect your devices to it |
|
||||
| [Keep secrets out of the Nix store](./secrets.md) | Your config holds links, keys or passwords |
|
||||
| [Control it day to day](./control.md) | Switching things without editing Nix or typing sudo |
|
||||
| [Use an AmneziaWG config](./amneziawg.md) | You have an AmneziaWG `.conf` or an Amnezia `vpn://` export |
|
||||
| [Chain proxies and add exits](./chains.md) | WARP, Tor, SSH, or reaching a server through another one |
|
||||
| [Other Linux and Android](./other-hosts.md) | You are not on NixOS |
|
||||
| [Get past mobile whitelists](./whitelist-bypass.md) | Mobile internet lets only whitelisted services through |
|
||||
@@ -0,0 +1,74 @@
|
||||
# Other Linux and Android
|
||||
|
||||
The same `services.proxy-suite` options work outside NixOS, through a module for each
|
||||
kind of host. The other guides apply as they are, within the limits below.
|
||||
|
||||
| Host | Module | Runs as |
|
||||
|---|---|---|
|
||||
| Any distribution, with [system-manager](https://github.com/numtide/system-manager) | `systemManagerModules.default` | root, in the system's systemd |
|
||||
| Any distribution, with [home-manager](https://github.com/nix-community/home-manager) | `homeManagerModules.default` | your user, in your systemd user session |
|
||||
| Android, with [Nix-on-Droid](https://github.com/nix-community/nix-on-droid) | `nixOnDroidModules.default` | the Nix-on-Droid app |
|
||||
|
||||
## system-manager
|
||||
|
||||
Nearly everything works as on NixOS: TUN, TProxy, zapret, the kill switch and the GUI.
|
||||
|
||||
```nix no-check
|
||||
systemConfigs.default = system-manager.lib.makeSystemConfig {
|
||||
modules = [
|
||||
proxy-suite.systemManagerModules.default
|
||||
{ services.proxy-suite = { enable = true; /* … */ }; }
|
||||
];
|
||||
};
|
||||
```
|
||||
|
||||
- Open inbound ports in your distribution's firewall yourself. proxy-suite leaves it alone.
|
||||
- AmneziaWG runs in userspace, since kernel modules cannot come from Nix here.
|
||||
|
||||
## home-manager
|
||||
|
||||
Rootless: only what an ordinary user can do.
|
||||
|
||||
```nix no-check
|
||||
homeConfigurations.me = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
proxy-suite.homeManagerModules.default
|
||||
{ services.proxy-suite = { enable = true; /* … */ }; }
|
||||
];
|
||||
};
|
||||
```
|
||||
|
||||
Available: the local proxy with its outbounds, subscriptions and routing, proxychains
|
||||
per-app routing, AmneziaWG as a `"userspace"` outbound, inbounds on ports 1024 and up, the
|
||||
GUI and the TUI.
|
||||
|
||||
Not available, since they need root: TUN, TProxy, the kill switch, zapret, per-app `tun`,
|
||||
`tproxy` and `zapret`, and AmneziaWG interfaces. `userControl` has nothing to grant, since
|
||||
you own the services. The build stops with a message if the config asks for any of these.
|
||||
|
||||
## Nix-on-Droid
|
||||
|
||||
What home-manager gets, without the GUI. Use `proxy-ctl` or `proxy-tui` in the app's shell.
|
||||
|
||||
```nix no-check
|
||||
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
proxy-suite.nixOnDroidModules.default
|
||||
{ services.proxy-suite = { enable = true; /* … */ }; }
|
||||
];
|
||||
};
|
||||
```
|
||||
|
||||
- Android has no boot hook for the app. The services start when a Nix-on-Droid shell opens,
|
||||
or on `proxy-suitectl boot`.
|
||||
- Android stops background apps. Keep the app's wake lock on, and turn off battery
|
||||
optimisation for it.
|
||||
- Point other apps at `127.0.0.1:1080`, in their own proxy settings or in the Wi-Fi proxy
|
||||
settings.
|
||||
|
||||
## See also
|
||||
|
||||
- [Keep secrets out of the Nix store](./secrets.md): secret files must be readable by your
|
||||
user on home-manager and Nix-on-Droid.
|
||||
@@ -0,0 +1,79 @@
|
||||
# Route a single app
|
||||
|
||||
Run one program through the proxy, or through zapret, and leave the rest of the system
|
||||
alone.
|
||||
|
||||
## Config
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
};
|
||||
perAppRouting = {
|
||||
enable = true;
|
||||
createDefaultProfiles = true; # a profile named after each method below
|
||||
proxychains.enable = true;
|
||||
tun.enable = true;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
## Run an app
|
||||
|
||||
```sh
|
||||
proxy-ctl apps # list profiles
|
||||
proxy-ctl apps run tun -- firefox
|
||||
proxy-ctl apps run proxychains -- curl https://example.com
|
||||
```
|
||||
|
||||
Run it as yourself, not with sudo.
|
||||
|
||||
## Which method
|
||||
|
||||
| Method | Covers | Notes |
|
||||
|---|---|---|
|
||||
| `proxychains` | TCP | Preloads a library into the app. Needs no privileges, but does not work with statically linked programs or most Go programs. |
|
||||
| `tun` | TCP and UDP | Puts the app in its own cgroup and routes it into a separate TUN. Works with any program. |
|
||||
| `tproxy` | TCP and UDP | Like `tun`, but intercepts with nftables. |
|
||||
| `zapret` | What zapret handles | No proxy: runs a separate zapret for the app, to get past DPI. |
|
||||
|
||||
`tun` works with any program. `proxychains` is handy for a quick command.
|
||||
|
||||
## Your own profiles
|
||||
|
||||
Name profiles after what they are for, to keep commands short:
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
};
|
||||
perAppRouting = {
|
||||
enable = true;
|
||||
tun.enable = true;
|
||||
profiles = [ { name = "browser"; route = "tun"; } ];
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Then run `proxy-ctl apps run browser -- chromium`.
|
||||
|
||||
## Good to know
|
||||
|
||||
- `tun`, `tproxy` and `zapret` profiles start a system service, so they ask for an admin
|
||||
password unless `userControl` grants the `perApp` scope (see
|
||||
[Control it day to day](./control.md)).
|
||||
- These three refuse to start while a global TUN or TProxy is running.
|
||||
- If `/etc/resolv.conf` points only at a local resolver (such as systemd-resolved on
|
||||
127.0.0.53), the app's DNS queries skip its route. `proxy-ctl` warns about this.
|
||||
- The app follows your [routing rules](./routing.md) like any other proxied traffic.
|
||||
|
||||
## See also
|
||||
|
||||
- [`perAppRouting.profiles`](../options/perAppRouting.md#services-proxy-suite-perapprouting-profiles)
|
||||
- [`perAppRouting.createDefaultProfiles`](../options/perAppRouting.md#services-proxy-suite-perapprouting-createdefaultprofiles)
|
||||
@@ -0,0 +1,109 @@
|
||||
# Choose what goes through the proxy
|
||||
|
||||
Decide per site whether traffic goes through the proxy, goes direct, or is blocked. This
|
||||
applies to the local proxy, TUN, TProxy and per-app routing alike.
|
||||
|
||||
## How a destination is routed
|
||||
|
||||
1. `proxy.routing.rules`, in order. The first match wins, and a rule can name a specific
|
||||
outbound.
|
||||
2. The `proxy`, `direct` and `block` lists.
|
||||
3. Anything left goes to `proxy.routing.default`: `"proxy"` (the default) or `"direct"`.
|
||||
|
||||
Russian sites and IPs go direct unless you set `routing.directRu = false`.
|
||||
|
||||
Each list and rule matches by `domains` (subdomains included), `ips` (CIDR), `geosites`,
|
||||
`geoips` and `ruleSets`.
|
||||
|
||||
## Only blocked sites through the proxy
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
routing = {
|
||||
default = "direct";
|
||||
proxy.domains = [ "youtube.com" "googlevideo.com" ];
|
||||
proxy.geosites = [ "instagram" ];
|
||||
};
|
||||
# Find blocked sites on its own, and route each one through an exit that reaches it.
|
||||
autoProxy.enable = true;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
`autoProxy` saves you from listing every blocked site. It probes new destinations in the
|
||||
background and routes only those that fail directly. It needs the sing-box backend.
|
||||
|
||||
## Everything through the proxy, with exceptions
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [
|
||||
{ tag = "nl-vps"; urlFile = "/run/secrets/nl-vps-url"; }
|
||||
{ tag = "us-vps"; urlFile = "/run/secrets/us-vps-url"; }
|
||||
];
|
||||
routing = {
|
||||
rules = [ { geosites = [ "netflix" ]; outbound = "us-vps"; } ];
|
||||
direct.domains = [ "bank.example" ];
|
||||
block.geosites = [ "category-ads-all" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
## Rule sets
|
||||
|
||||
Rule sets are lists that sing-box downloads and refreshes on its own, so they stay current
|
||||
without a rebuild. Name them in `routing.ruleSets` and use them in any `ruleSets` list:
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
routing = {
|
||||
default = "direct";
|
||||
ruleSets.blocked.url = "https://example.com/blocked.srs";
|
||||
proxy.ruleSets = [ "blocked" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
They need the sing-box or hybrid backend.
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
proxy-ctl where youtube.com # how a site is routed right now, and why
|
||||
proxy-ctl proxy mode whitelist # direct unless a rule says otherwise
|
||||
proxy-ctl proxy mode blacklist # proxy unless a rule says otherwise
|
||||
proxy-ctl proxy mode all-proxy # everything through the proxy, except blocks
|
||||
proxy-ctl proxy mode all-bypass # everything direct, except blocks
|
||||
proxy-ctl proxy mode default # back to routing.default
|
||||
proxy-ctl proxy auto # what autoProxy routed, and where
|
||||
proxy-ctl proxy rulesets update # refetch rule sets now
|
||||
```
|
||||
|
||||
A route mode set with `proxy-ctl` lasts until the next reboot.
|
||||
|
||||
## Good to know
|
||||
|
||||
- Geosite and geoip names come from the [geodata](../options/geodata.md) databases.
|
||||
- With `zapret`, sites that zapret handles are sent direct, so zapret can unblock them. See
|
||||
[Unblock sites without a server](./zapret.md).
|
||||
- To send some sites to WARP, Tor or another exit, see [Chain proxies and add exits](./chains.md).
|
||||
|
||||
## See also
|
||||
|
||||
- [`proxy.routing.rules`](../options/proxy.md#services-proxy-suite-proxy-routing-rules)
|
||||
- [`proxy.routing.default`](../options/proxy.md#services-proxy-suite-proxy-routing-default)
|
||||
- [`proxy.routing.ruleSets`](../options/proxy.md#services-proxy-suite-proxy-routing-rulesets)
|
||||
- [`proxy.autoProxy`](../options/proxy.md#services-proxy-suite-proxy-autoproxy-enable)
|
||||
@@ -0,0 +1,67 @@
|
||||
# Keep secrets out of the Nix store
|
||||
|
||||
Everything in a Nix config is copied to `/nix/store`, which every user on the machine can
|
||||
read. That includes proxy links, passwords and keys. So every option that holds a secret has
|
||||
a `…File` twin, which takes a path that is read when the service starts:
|
||||
|
||||
| Inline (ends up in the store) | Use instead |
|
||||
|---|---|
|
||||
| `url` | `urlFile` |
|
||||
| `password` | `passwordFile` |
|
||||
| `uuid` | `uuidFile` |
|
||||
| `vpn` | `vpnFile` |
|
||||
| `privateKey` | `privateKeyFile` |
|
||||
| `secret` | `secretFile` |
|
||||
|
||||
The option reference marks each inline one with "Ends up in the Nix store".
|
||||
|
||||
A file can stay owned by root with mode `0400`. The services read it as root when they start.
|
||||
With home-manager and Nix-on-Droid, your own user must be able to read it.
|
||||
|
||||
## With sops-nix
|
||||
|
||||
```nix no-check
|
||||
sops.secrets."proxy/my-vps-url" = { };
|
||||
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [
|
||||
{ tag = "my-vps"; urlFile = config.sops.secrets."proxy/my-vps-url".path; }
|
||||
];
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
## With agenix
|
||||
|
||||
```nix no-check
|
||||
age.secrets.my-vps-url.file = ./secrets/my-vps-url.age;
|
||||
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [
|
||||
{ tag = "my-vps"; urlFile = config.age.secrets.my-vps-url.path; }
|
||||
];
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
## Without a secrets tool
|
||||
|
||||
Any path outside the store works, such as a root-only file you create by hand:
|
||||
|
||||
```sh
|
||||
sudo install -D -m 0400 /dev/stdin /var/lib/proxy-secrets/my-vps-url <<< 'vless://…'
|
||||
```
|
||||
|
||||
## Good to know
|
||||
|
||||
- A secret file that changes takes effect on the next restart: `proxy-ctl restart`.
|
||||
- Anything added at runtime with `proxy-ctl` (outbounds, subscriptions) is kept outside the
|
||||
store, readable by root and by the `userControl` group.
|
||||
- Share links, subscription URLs and running configs contain secrets too. `proxy-ctl` shows
|
||||
them only to root, and to `userControl` members with the `secrets` scope.
|
||||
@@ -0,0 +1,110 @@
|
||||
# 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:
|
||||
|
||||
```sh
|
||||
nix build github:FUFSoB/proxy-suite-flake#installer-iso
|
||||
```
|
||||
|
||||
Boot the VPS from it. The console installer asks for the public IP, users, an optional
|
||||
domain and the disk to erase, then installs NixOS with `nixosModules.server`: VLESS
|
||||
REALITY, TLS and WS listeners, ACME certificates and SSH. After the reboot, log in and run:
|
||||
|
||||
```sh
|
||||
proxy-ctl inbounds link vless-reality --qr
|
||||
```
|
||||
|
||||
## An existing NixOS host
|
||||
|
||||
```nix
|
||||
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…"; # from the same `xray x25519` run
|
||||
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](./secrets.md)).
|
||||
To make them:
|
||||
|
||||
```sh
|
||||
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`](../options/inbounds.md#services-proxy-suite-inbounds-listeners).
|
||||
|
||||
## Share access
|
||||
|
||||
```sh
|
||||
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:
|
||||
|
||||
```nix
|
||||
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 needs `proxy.enable`. A listener can also exit
|
||||
through one outbound with `via = "<tag>"`.
|
||||
- For clients that cannot reach the server at all, `tor.onionService` serves the
|
||||
listeners over Tor too.
|
||||
|
||||
## See also
|
||||
|
||||
- [`inbounds.listeners`](../options/inbounds.md#services-proxy-suite-inbounds-listeners)
|
||||
- [`inbounds.routing.via`](../options/inbounds.md#services-proxy-suite-inbounds-routing-via)
|
||||
- [`inbounds.subscriptions`](../options/inbounds.md#services-proxy-suite-inbounds-subscriptions-enable)
|
||||
- [`tor.onionService`](../options/tor.md#services-proxy-suite-tor-onionservice-enable)
|
||||
@@ -0,0 +1,61 @@
|
||||
# Route the whole machine
|
||||
|
||||
Send every app's traffic through the proxy, including apps with no proxy settings. There
|
||||
are two global modes, and either can start at boot.
|
||||
|
||||
## Config
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy = {
|
||||
enable = true;
|
||||
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
|
||||
tun.enable = true;
|
||||
autostart = "tun"; # or null, to start it by hand
|
||||
};
|
||||
killSwitch.enable = true;
|
||||
};
|
||||
```
|
||||
|
||||
## TUN or TProxy
|
||||
|
||||
- **TUN** adds a virtual network interface and routes everything into it. It is the usual
|
||||
pick.
|
||||
- **TProxy** intercepts TCP and UDP with nftables instead of adding an interface. Pick it if
|
||||
this host is a gateway for other devices: list their interfaces in
|
||||
`proxy.tproxy.lanInterfaces` (NixOS needs `networking.nftables.enable` for that).
|
||||
|
||||
You can enable both and switch between them. Starting one global mode stops the other, and
|
||||
an AmneziaWG profile running as a global VPN counts as one too.
|
||||
|
||||
Your [routing rules](./routing.md) still apply in both modes. Sites that the rules send
|
||||
direct skip the proxy.
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
proxy-ctl proxy tun on # or: off, toggle, restart
|
||||
proxy-ctl proxy tproxy on
|
||||
proxy-ctl status # which mode is running
|
||||
proxy-ctl killswitch # kill switch state
|
||||
proxy-ctl killswitch off # lift the kill switch without stopping the tunnel
|
||||
```
|
||||
|
||||
## Good to know
|
||||
|
||||
- The kill switch blocks outgoing traffic while the tunnel restarts or after it fails, so
|
||||
nothing leaks. LAN, DHCP and NTP stay open. Turning the tunnel off lifts it.
|
||||
- If the uplink has no IPv6, set `proxy.dns.strategy = "ipv4_only"` (sing-box). Otherwise
|
||||
direct IPv6 connections hang instead of falling back to IPv4.
|
||||
- `proxy.tproxy.localSubnets` lists networks that skip TProxy. Add your LAN and VM bridges if
|
||||
they are not in `192.168.0.0/16`.
|
||||
- Per-app `tun`, `tproxy` and `zapret` profiles refuse to start while a global mode is on.
|
||||
|
||||
## See also
|
||||
|
||||
- [`proxy.tun`](../options/proxy.md#services-proxy-suite-proxy-tun-enable)
|
||||
- [`proxy.tproxy`](../options/proxy.md#services-proxy-suite-proxy-tproxy-enable)
|
||||
- [`proxy.autostart`](../options/proxy.md#services-proxy-suite-proxy-autostart)
|
||||
- [`killSwitch.enable`](../options/killSwitch.md#services-proxy-suite-killswitch-enable)
|
||||
- [`proxy.ipv6`](../options/proxy.md#services-proxy-suite-proxy-ipv6)
|
||||
@@ -0,0 +1,87 @@
|
||||
# Get past mobile whitelists
|
||||
|
||||
Some mobile networks let through only a whitelist of services, such as video calls, and
|
||||
block everything else. [whitelist-bypass](https://github.com/kulikov0/whitelist-bypass)
|
||||
tunnels your traffic through a video call on a whitelisted platform.
|
||||
|
||||
It takes two machines:
|
||||
|
||||
- a **creator** on a host with normal internet access, such as a VPS or a home machine. It
|
||||
logs in to the call platform, starts a call and relays traffic to the internet;
|
||||
- a **joiner** on the censored side, such as a laptop on mobile internet. It joins that call
|
||||
and becomes an outbound for the proxy.
|
||||
|
||||
Supported platforms: `"wbstream"`, `"telemost"`, `"dion"` and `"bitrix"`. Each needs an
|
||||
account for the creator.
|
||||
|
||||
## The creator
|
||||
|
||||
One creator per joiner device.
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
whitelistBypass = {
|
||||
enable = true;
|
||||
creators.laptop = {
|
||||
platform = "wbstream";
|
||||
cookiesFile = "/run/secrets/wbstream-cookies.json";
|
||||
};
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
The cookies come from the upstream desktop Creator app. They are read on first start, and
|
||||
the login refreshes itself after that. `proxy-ctl wl auth laptop` replaces them at runtime,
|
||||
and asks for an email and password instead on DION and Bitrix.
|
||||
|
||||
The creator starts a call and keeps reusing it. Get its link with:
|
||||
|
||||
```sh
|
||||
proxy-ctl wl link laptop
|
||||
```
|
||||
|
||||
## The joiner
|
||||
|
||||
The joiner is an outbound tagged with its name (`wl` here), so it needs the local proxy.
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
proxy.enable = true;
|
||||
whitelistBypass = {
|
||||
enable = true;
|
||||
joiners.wl.platform = "wbstream";
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Give it the creator's link, then send traffic through it:
|
||||
|
||||
```sh
|
||||
proxy-ctl wl join wl 'https://…' # the link from `proxy-ctl wl link`
|
||||
proxy-ctl proxy pin wl
|
||||
```
|
||||
|
||||
The link can also come from a file, with `joiners.<name>.linkFile`.
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
proxy-ctl wl # creators and joiners, and their state
|
||||
proxy-ctl wl new laptop # start a new call, if the platform closed the old one
|
||||
proxy-ctl wl restart # restart all of them; or name one
|
||||
```
|
||||
|
||||
## Good to know
|
||||
|
||||
- By default, the creator's traffic exits straight from its host. With
|
||||
`creators.<name>.upstream = "proxy"`, it goes through that host's own proxy and routing.
|
||||
- Use it when nothing else gets through, and `proxy-ctl proxy unpin` once other outbounds
|
||||
work again.
|
||||
- Pair it with [Route the whole machine](./system-wide.md) on the joiner to cover every app.
|
||||
|
||||
## See also
|
||||
|
||||
- [`whitelistBypass.creators`](../options/whitelistBypass.md#services-proxy-suite-whitelistbypass-creators)
|
||||
- [`whitelistBypass.joiners`](../options/whitelistBypass.md#services-proxy-suite-whitelistbypass-joiners)
|
||||
@@ -0,0 +1,79 @@
|
||||
# Unblock sites without a server
|
||||
|
||||
zapret gets around DPI blocking by changing how the first packets of a connection look. It
|
||||
needs no proxy server: the traffic still goes straight to the site. It only helps with
|
||||
blocks that DPI enforces, and not with sites whose IPs are blocked outright.
|
||||
|
||||
## Ready-made presets: zapret-discord-youtube
|
||||
|
||||
The default engine. It covers YouTube and Discord out of the box.
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
zapret = {
|
||||
enable = true;
|
||||
zapret-discord-youtube = {
|
||||
configName = "general(ALT)"; # the default; try others if it does not work
|
||||
domains = [ "rutracker.org" ]; # more sites to unblock
|
||||
};
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Which preset works depends on your ISP. If sites still do not load, try other presets from
|
||||
the [zapret-discord-youtube](https://github.com/kartavkun/zapret-discord-youtube) list, such
|
||||
as `"general (ALT9)"`.
|
||||
|
||||
## Blocked sites found automatically: zapret2
|
||||
|
||||
zapret2 notices failing connections, marks the site as blocked, and finds a strategy that
|
||||
works for it. Each site's strategy is remembered.
|
||||
|
||||
```nix
|
||||
services.proxy-suite = {
|
||||
enable = true;
|
||||
zapret = {
|
||||
enable = true;
|
||||
engine = "zapret2";
|
||||
zapret2.domains = [ "rutracker.org" ]; # always treated as blocked
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
`zapret2.strategySource = "z2k"` switches to z2k's strategies and site lists, which include
|
||||
the full RKN list and use more memory. It also turns on a workaround for ISPs that cut
|
||||
TLS to some hosting networks after about 16 KB.
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
proxy-ctl zapret # status
|
||||
proxy-ctl zapret off # or: on, toggle, restart
|
||||
proxy-ctl zapret auto # sites zapret2 learned
|
||||
proxy-ctl zapret auto add example.com # treat a site as blocked
|
||||
proxy-ctl zapret auto exclude example.com # never touch or learn a site
|
||||
proxy-ctl zapret auto forget example.com # forget it and its strategy
|
||||
proxy-ctl zapret cutoff # networks cut off at 16 KB (z2k)
|
||||
```
|
||||
|
||||
## With a proxy
|
||||
|
||||
zapret and the proxy work side by side. By default (`zapret.directSync`), the sites zapret
|
||||
handles are sent direct, so they skip the proxy and reach zapret. Everything else follows
|
||||
your [routing rules](./routing.md).
|
||||
|
||||
To use zapret for a single app only, see [Route a single app](./per-app.md).
|
||||
|
||||
## Good to know
|
||||
|
||||
- zapret needs root, so it is not available with home-manager or Nix-on-Droid.
|
||||
- If it breaks VMs or containers behind NAT, list their subnets in `zapret.cidrExemption`.
|
||||
- For games, set `zapret-discord-youtube.gameFilter`.
|
||||
|
||||
## See also
|
||||
|
||||
- [`zapret.engine`](../options/zapret.md#services-proxy-suite-zapret-engine)
|
||||
- [`zapret-discord-youtube.configName`](../options/zapret.md#services-proxy-suite-zapret-zapret-discord-youtube-configname)
|
||||
- [`zapret2.strategySource`](../options/zapret.md#services-proxy-suite-zapret-zapret2-strategysource)
|
||||
- [`zapret.directSync`](../options/zapret.md#services-proxy-suite-zapret-directsync-enable)
|
||||
Reference in new issue
Block a user