For readers who have already configured their own servers and want to add domain exceptions, IP routing, or blocking rules in Shadowrocket. Check which configuration is active, order rules from specific exceptions to broader matches, and put FINAL last. Then use new connections to verify which policy each request matches.
Before you start: Set Global Routing to Config
The steps below use iPhone and iPad as examples. Go to Home → Global Routing and make sure Config is selected. Then open Config and check which configuration file is active. These checks serve different purposes: the first determines whether traffic follows the configuration, while the second determines which rules are used. Edits won't affect connections if a different configuration is active.
Troubleshooting order: check the mode before changing rules
If every request uses the same policy before and after your changes, first switch to Config and check which file is active. Then test a new connection that should match REJECT. If nothing changes, check whether an earlier rule is matching first.
Proxy and Direct are Global Routing modes for routing all traffic through a proxy or directly, respectively. They are not the PROXY and DIRECT actions used at the end of rules. To verify the rule order in this guide, select Config first so that settings under Scene don't affect the result.
Setup: Put specific exceptions before general rules
- Keep a copy of the original configuration. In Config, find the file currently in use and save an unchanged copy. Then edit a local configuration you can modify. If the original file is updated remotely, check that your local changes are still present after refreshing it.
- Find the insertion point in the existing
[Rule]section. First look for domain rules that overlap your target, then for broader IP or region rules. Specific exceptions must go beforeFINALand any general rule that could match first. If aFINALrule already exists, edit that line as needed rather than adding another fallback after it. - Save and confirm the active configuration. If you edited a copy, switch to that file. Return to Home, make sure Global Routing is set to Config, and turn on the connection. To test
PROXY, make sure the server you configured is selected under SERVER.
The following example shows rule order; it isn't a template to replace your entire file. example.com is used to demonstrate domain matching, and 192.0.2.0/24 is a documentation-only example network, not a way to test whether a service is reachable. For testing, substitute a target you control.
[Rule]
DOMAIN,metrics.example.com,REJECT
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.0.2.0/24,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY
How rule matching works: the first match wins
Rules are checked in the order they appear in the file. Shadowrocket doesn't collect every match and then choose the most specific one. For example, if Shadowrocket identifies the destination as metrics.example.com, the first DOMAIN rule matches and applies REJECT. Move DOMAIN-SUFFIX,example.com,PROXY above it, and the same host matches the suffix rule first and uses PROXY. The exact-match rule below it won't run.
What domain rules, IP rules, and fallbacks do
Handle domain exceptions first
- DOMAIN
metrics.example.com,REJECT: Matches this hostname only.- DOMAIN-SUFFIX
example.com,PROXY: Matches this domain and its subdomains, but notnotexample.com.- What it matches
- A hostname, not a full URL or a URL path.
When a domain suffix has exceptions, put the exact DOMAIN rule before DOMAIN-SUFFIX.
Then handle destination IPs and fallbacks
- IP-CIDR
192.0.2.0/24,DIRECT,no-resolve: Matches the specified IPv4 range without resolving a domain specifically for this rule.- GEOIP
CN,DIRECT: Matches based on the destination IP's geographic classification, not the domain suffix.- FINAL
PROXY: Takes no destination parameter and catches requests that haven't matched an earlier rule.
If an IP range should use a different policy from the region's default, put IP-CIDR before the corresponding GEOIP rule.
GEOIP uses the destination IP, not the device's location. A domain that resolves to multiple addresses may resolve differently depending on the network or time, so domain rules are more reliable than GEOIP for domain-specific exceptions. In this example, no-resolve applies only to its IP-CIDR rule; it doesn't disable DNS resolution for the entire configuration. Later rules may still need the destination IP.
How to test: distinguish rule matches from reachability with new connections
Don't rely on whether a webpage loads. DIRECT means traffic isn't routed through a proxy; it doesn't guarantee the destination is reachable. PROXY selects a proxy route, but doesn't guarantee a response from the remote host. Connectivity Test can help check a connection, but its results don't replace checking the specific domain and the rule it actually matched.
- Test REJECT: Replace the exception domain with a reachable test host you control, then start a new connection. With the exact-match rule first, the request should be rejected. A browser may show only a generic network error, so the error message alone won't tell you which rule took effect.
- Test DOMAIN-SUFFIX: Use another test host under the same parent domain that isn't listed as an exact-match exception. It should match the suffix rule and use
PROXY. To check whether a rule is being shadowed, swap the two domain rules in a test copy and see whether the host that was previously rejected gets a different policy. Restore the original order when you're done. - Test IP-CIDR: Use a reachable IPv4 address and range that you manage, and test by connecting directly to the IP. Accessing the same service by domain isn't an equivalent test: with
no-resolveenabled, this rule won't look up the domain's address to find a match. - Test FINAL: Choose a test target that matches no earlier rule, including
GEOIP. A target that matches a regional rule first cannot testFINAL, even if it matches no domain rule.
Change one rule or one position at a time, then retest with a new connection. If request logs are available, check the destination and applied policy first, then check the specific matching rule if shown. If the app reuses an existing connection, simply refreshing the page may not trigger a new routing decision. Close that connection before testing again.
Common issues: rules not matching, editing the wrong file, and path matching
Why does a request still use PROXY when the exact domain rule is correct?
First check whether the request's actual destination is the hostname in your rule. Then check whether an earlier DOMAIN-SUFFIX rule covers the same domain. For example, if the suffix rule for example.com comes first, it may shadow the exact rule for metrics.example.com. Move the exact rule above the suffix rule, save, and start a new connection.
I edited the file in Config. Why hasn't anything changed?
In Home → Global Routing, make sure Config is selected. Then return to Config and check that the active file is the copy you edited. Also make sure the new rules in the [Rule] section aren't placed after FINAL.
Can I reject only the /metrics path on example.com?
The DOMAIN and DOMAIN-SUFFIX rules in this guide can't distinguish paths on the same hostname. Don't add /metrics to the domain parameter. If the request uses a separate hostname, you can match it with an exact DOMAIN rule. If it shares a hostname with regular traffic, applying REJECT to the whole domain will also affect legitimate requests to that host.
Should FINAL use PROXY or DIRECT?
Choose based on where you want unmatched traffic to go by default. To proxy only listed destinations, assign them PROXY and finish with FINAL,DIRECT. To proxy everything except specific exceptions, list direct and rejected exceptions first, then finish with FINAL,PROXY. After editing, retest with a destination that doesn't match any earlier rule.