3.8 KiB
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
proxy.routing.rules, in order. The first match wins, and a rule can name a specific outbound.- The lists:
proxy.domainsandproxy.ipsfirst, thenblock, thendirect, thenproxy.geosites,proxy.geoipsandproxy.ruleSets. A name in both a block and a direct list (an ad domain undercategory-ru, say) is blocked. - 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
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
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:
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
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 databases.
- With
zapret, sites that zapret handles are sent direct, so zapret can unblock them. See Unblock sites without a server. - To send some sites to WARP, Tor or another exit, see Chain proxies and add exits.