Back to blog
NO.
034
DATE
READ
~8 min
KIND
Notes
STATUS
Reviewed

TAGS: Tools

Two Sites, Two Proxy Exits with sing-box

Route two websites through different proxy exits with domain rules in GUI.for.SingBox on Windows: a minimal config, connection-log checks, and limits.

Two websites each need a different proxy exit. Site A does not work through node 1 but does through node 2; site B is the reverse. Switching the global node by hand before each visit gets one site working at a time, but not both at once.

On Windows with GUI.for.SingBox v1.25.4, I used two domain routing rules: site A always goes out through exit 2, site B through exit 1. Access tests for both sites passed, and the Connections panel showed the matched domain rule and the chosen outbound chain for each. This post covers the minimal configuration and how to verify it, then which more elaborate features are worth considering later.

IP1 and IP2 here are the public exit IPs of two different proxy nodes, not IPv4 and IPv6. "Does not work" only means that in this test the node could not reach a particular service; it says nothing about which kind of ban or risk-control policy the site uses.

Minimal goal: pick the proxy exit by domain

The intended traffic path is simple:

Windows / Chrome
  └─ GUI.for.SingBox (rule mode)
      ├─ Site A domain → dedicated outbound A → node 2
      ├─ Site B domain → dedicated outbound B → node 1
      └─ Other domains → existing routing rules

This assumes both nodes are already configured in the client, and that you have checked the accessibility described above by switching nodes one at a time. Confirm first that their public exit IPs really differ; two node names do not guarantee two different exits.

Keep your existing configuration and add only the two most specific rules:

  1. Under outbound settings (「出站设置」), create two manual-select groups, for example site-a-out and site-b-out, and pick the node that can reach each site. You can also point a routing rule straight at an existing node tag; a group is not required.
  2. Under routing settings → rules (「路由设置 → 规则」) for the current profile, add a domain suffix (domain_suffix) match for each site. Set the action to route and the outbound to the tag you just created.
  3. Use rule mode (rule). Put these two routes ahead of any broader rule that could match first, such as the default proxy, direct, or region rules.
  4. Save and reload the configuration, close the old connections to those sites, then visit them again.

The official illustrated GUI.for.SingBox guide uses v1.9.0 as its example, and the setting names above come from it. The client tested this time was v1.25.4. Menu locations may change, so rely on the configuration the current version generates and on the connection log.

In the sing-box configuration, the core part looks roughly like this (a rule fragment only; do not overwrite your whole existing configuration with it):

{
  "route": {
    "rules": [
      {
        "domain_suffix": ["site-a.example"],
        "action": "route",
        "outbound": "site-a-out"
      },
      {
        "domain_suffix": ["site-b.example"],
        "action": "route",
        "outbound": "site-b-out"
      }
    ]
  }
}

site-a.example, site-b.example and the two outbound tags are examples. Replace them with your own domains and outbound tags that already exist. The inbounds, outbound nodes, DNS and existing routing rules that a working configuration needs are omitted here.

How to tell the routing worked

A page that loads is not enough. Sometimes a site is temporarily reachable through both nodes, or an existing connection has not been re-established under the new rule.

In the Connections panel of GUI.for.SingBox, the two domain_suffix rules were routed to their own dedicated groups, and the final chain showed the expected node in each case. This matched the actual access results for the two sites.

The real sites, nodes and server identifiers are left out of this public record. The connection structure is transcribed below; it is not a verbatim copy of the original log:

domain_suffix=<site A domain> => route(<dedicated outbound A>) => <node 2>
domain_suffix=<site B domain> => route(<dedicated outbound B>) => <node 1>

The Connections panel shows which rule the client matched and which node it selected internally. It does not by itself show the public IP the site's server saw. For a stricter check, use a trustworthy exit-IP lookup service under the same node conditions, or read the server-side records on a target service you control. A third-party site loading successfully does not mean some IP-based risk control has been lifted for good.

If a rule does not match, check the work mode, the rule order and the target domain shown in the connection first. For TUN traffic, or traffic where only the target IP is available, then check DNS and protocol sniffing. There is no need to rewrite the whole configuration at the start.

Why not solve it with the Windows hosts file

The Windows hosts file maps a local host name to a target IP address, for example pointing example.com at a particular server. Microsoft's documentation on the hosts file describes this same purpose. It changes which target address you go to, not which local proxy node the traffic leaves through.

The two problems sit at different layers:

Hosts / DNS       domain → target server IP
sing-box routing  destination → which outbound node

If a site is served through a CDN or from several regions, pinning the target address can also break things when addresses move or when certificates and server-side routing differ. Some proxy-side resolution paths may not use the Windows hosts file at all.

The hosts file still has its uses, for example verifying a new server for a site you run yourself before switching DNS. For "site A through proxy IP2, site B through proxy IP1", though, it cannot choose the exit.

When the domain list grows: consider a rule-set

With only two sites and two domain suffix rules, writing them one by one is the clearest option. If a service later uses a main site, a login domain and a separate API domain, you can put them in one rule-set and point the whole set at a single outbound.

sing-box supports inline, local (local file) and remote (remote file) rule sets. The example below shows only how an inline rule set relates to one route, and is again a partial configuration:

{
  "route": {
    "rule_set": [
      {
        "type": "inline",
        "tag": "service-a-domains",
        "rules": [
          {
            "domain_suffix": [
              "site-a.example",
              "auth-a.example"
            ]
          }
        ]
      }
    ],
    "rules": [
      {
        "rule_set": ["service-a-domains"],
        "action": "route",
        "outbound": "site-a-out"
      }
    ]
  }
}

The benefit is that several domains share one outbound policy, and adding or removing domains happens in one place. The cost is maintaining the rule set, the tag references, and troubleshooting failed updates. A remote rule set can also update itself, but then you have to consider the trustworthiness of the source, content changes, the download path and caching. For two stable domains, a remote rule set mostly adds an unnecessary dependency.

Other official settings: when to move up

FeatureWhen it helpsCost or limit
domain and domain_suffixMatch an exact domain only, or manage a domain together with its subdomainsA suffix rule covers more; the service may also use third-party authentication domains
selector (manual select)A service needs a fixed, specified exitWhen the node is down you switch by hand or arrange a backup node in advance
urltest (automatic select)All nodes in the group work with the target service and you only want lower connection latencyA reachable test URL with low latency does not mean a particular site will load
Process matchingDifferent applications on the same computer need different routesMatching the process cannot tell two sites in Chrome apart, and depends on the client obtaining process information
DNS rules and sniffThe connection carries only an IP and the domain rule did not match as expectedNeeds checking together with the inbound, the resolution path and protocol conditions; the domain cannot be reliably extracted from all traffic
TUN inboundYou need to proxy applications that do not follow the system proxy settingTakes over traffic more broadly, but involves the virtual adapter, routing, firewall and network loop troubleshooting

You do not need to enable all of these at once. In particular, avoid putting two mutually incompatible exits in the same urltest group: automatic selection usually goes by the latency of a test URL, not by whether site A or site B is actually reachable.

If you only visit the two sites from a browser that follows the system proxy, rule mode with domain routing is enough. If there are applications that ignore the proxy and that you do need to capture, evaluate TUN then, and follow the official notes on settings such as automatic detection of the outbound interface.

Boundary: routing solved is not every access limit solved

This approach holds under these conditions: the local traffic already enters sing-box; the target domain is available for matching; the two rules match first; and the two chosen nodes still work and their public exits are what you expect.

It does not guarantee that a site's account, session, regional policy or server-side access limits will allow the use, and it does not automatically handle third-party login and resource domains beyond the main site. When a login misbehaves, first check which domains the connection log shows were actually requested, then add rules in the narrowest scope. Do not bind the domains of an entire large CDN to one node.

For now, access to both sites works with the minimal routing. What remains is keeping the two rules readable and checkable; a rule set, a more involved DNS policy or TUN is worth introducing only if the number of domains or the range of applications really grows.

Writing note: GPT-6 drafted it, Claude Sonnet 5.5 translated it; the author supplied tests and screenshots.

Comments →

CC BY-NC-SA 4.0

Comments

Comments are powered by GitHub Discussions. Sign in with GitHub to comment. Open the matching Discussion