Shadowrocket rules combine matching conditions with actions. This guide is for users with their own service provider and subscription who are ready to adjust a configuration file: first set Global Routing to Config, then order rules with specific exceptions first, broader conditions next, and FINAL last. Finally, test the result with the same request. Examples explain syntax only; no nodes or subscriptions are provided.
1. Set Global Routing to Config before checking rules
Adding rules to a file does not guarantee that current requests use that file. Home manages connections and service entries, Config manages configuration files, and Settings contains app preferences. When troubleshooting, first confirm which configuration the connection uses, then check Home → Global Routing. The rule explanations here assume Config is selected; they do not apply when Proxy or Direct is temporarily overriding rule-based routing.
Config
RecommendedRequests follow the rules in the current configuration. Whether a request uses PROXY, DIRECT, or REJECT depends on the rule it matches, not on this mode in advance.
Use it to write rules, verify match order, and route traffic according to your configuration.
Proxy
Routes traffic through a proxy instead of applying the per-rule results described here. You can use it to compare whether the same destination connects through a proxy, but it does not validate your rules.
Use it briefly to compare a proxy connection with routing in Config.
Direct
Routes traffic directly to its destination. If Direct is selected, adding a PROXY rule to the configuration alone does not prove that the rule is active.
Use it to compare access to a destination over your local network.
Scene in Global Routing involves selecting a scene, so check which settings the current scene uses. It is not a rule keyword to add inside [Rule]. For an initial rule test, switch explicitly to Config to reduce variables. Settings → On Demand controls when connections are triggered; it does not change rule order.
Takeaway: Fix the routing mode first, then change one rule
If the result changes only after switching to Config, check the previous Global Routing or scene settings first. Avoid changing DNS, service entries, and rule order at the same time, or you will not know which change made the difference.
2. Rule syntax: condition first, action last
Rules go in the [Rule] section of a configuration file. Most common rules follow the format “type,match value,policy,” with fields separated by ASCII commas. The three lines below show an exact domain, a domain suffix, and a final policy. The example domains illustrate syntax and should not be copied as a real-world service list.
[Rule]
DOMAIN,api.example.com,PROXY
DOMAIN-SUFFIX,example.com,DIRECT
FINAL,PROXY
| Policy | What it does | What to check |
|---|---|---|
PROXY | Routes the request through a proxy. | Check that the selected proxy is available. If your configuration uses a custom policy group, check its selected option as well. |
DIRECT | Connects directly to the destination without using a proxy policy. | The destination must be reachable from your local network. Matching DIRECT does not guarantee a successful connection. |
REJECT | Rejects matching requests. | Make sure the condition is specific enough to avoid blocking sign-in, images, or other required resources. |
PROXY is neither a server address nor a protocol name. Shadowsocks, VMess, VLESS, Trojan, Hysteria2, and WireGuard are connection protocols. Rules determine which policy a request uses; service entries provide the actual connection parameters. Do not put a protocol name, subscription URL, or server port in a rule’s policy field. If you use a custom policy group, its name must exactly match the one defined in the configuration.
3. Rule order: once a rule matches, later rules are skipped
Rules are checked from top to bottom, and the policy for the first match is applied. Rules do not automatically prioritize more specific matches, and matching results are not combined. In the example above, api.example.com matches DOMAIN first and uses PROXY. img.example.com does not match the first line, so it matches DOMAIN-SUFFIX next and uses DIRECT.
- Put specific exceptions first. Place exact-domain rules before broader suffix rules. For example, put
DOMAIN,api.example.com,PROXYbeforeDOMAIN-SUFFIX,example.com,DIRECT. - Then add broader rules. DOMAIN-SUFFIX matches both the specified domain and its subdomains.
example.commatchesexample.comanda.example.com, but not any domain that merely contains that text. - Place reject rules carefully. If you put
DOMAIN-SUFFIX,example.com,REJECTfirst, a later rule allowingapi.example.comwill never run. - Put FINAL last. The final policy applies only if none of the preceding conditions match. Rules after FINAL cannot serve as normal follow-up matches.
Swapping the first two lines changes the outcome. In the example below, api.example.com matches the first line and connects directly. The second line is more specific, but it cannot override a result that has already been determined.
[Rule]
DOMAIN-SUFFIX,example.com,DIRECT
DOMAIN,api.example.com,PROXY
FINAL,PROXY
4. How FINAL works with IP rules
FINAL takes no domain or network argument. Its correct format is FINAL,policy, for example FINAL,PROXY or FINAL,DIRECT. It is not a retry mechanism: if a PROXY rule matches but the connection fails, processing does not continue to FINAL and switch to DIRECT. FINAL applies when no matching condition is found, not when a connection fails.
| Rule syntax | What it matches | Common point of confusion |
|---|---|---|
DOMAIN-SUFFIX,example.com,PROXY | The domain suffix identified in the request. | Do not include https:// in the match value or add a page path. |
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve | Whether the destination IPv4 address falls within the specified network. | /16 specifies the network prefix, not a port. This example covers 192.168.0.0 through 192.168.255.255. |
GEOIP,CN,DIRECT | The geographic location associated with the destination IP in the geolocation database. | It does not match based on page content, domain suffix, or the user’s location. |
FINAL,PROXY | No preceding rule matched. | No match value is needed; put this rule last. |
no-resolve prevents an additional DNS lookup from being triggered just to match this IP rule. It does not disable DNS for the entire app or turn a domain into an IP address. If the request already includes a usable destination IP, the rule can still check that IP. If the request has only a domain and no usable IP yet, do not assume this rule will match.
GEOIP results depend on the destination IP and the local database. Different DNS results for the same domain can lead to different geographic matches. For a small number of domains that must use a fixed policy, add explicit DOMAIN or DOMAIN-SUFFIX exceptions before broader conditions such as GEOIP. Do not treat successful DNS resolution, a rule match, and a successful connection as the same thing.
[Rule]
DOMAIN,api.example.com,PROXY
DOMAIN-SUFFIX,example.com,DIRECT
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY
The example shows one possible rule order, not a complete configuration or a list recommended for every network. Before using it, make sure the local network range, destination domains, and final policy suit your needs. If the destination uses IPv6, an IPv4 IP-CIDR rule alone will not cover its IPv6 address; check the relevant rules and network conditions separately.
5. How to verify rule matches after saving
Test a new connection, not a page that is already open. A browser may reuse an existing connection, and a page may show cached content. Whether the page still loads does not tell you whether the rule you just changed took effect. Save a copy of the original configuration first, and change only one condition or policy at a time during testing.
-
Confirm the configuration
Open Config and confirm which file is selected. Edit and save the file’s
[Rule]section; do not change only a different, inactive copy. -
Fix the routing mode
Go to Home → Global Routing → Config and confirm that Config is selected, not Proxy, Direct, or a Scene you have not checked.
-
Reconnect
Apply the updated configuration and make the request again, disconnecting and reconnecting if needed. Close the test page’s existing connection to avoid mistaking connection reuse for a rule that failed to take effect.
-
Check the logs
Check the request log for the actual destination domain or IP, the matched rule, and the policy used. If a page involves multiple domains, distinguish the main document, sign-in endpoints, and resource requests.
-
Revert test changes
Record the original rule, your changes, and the results, then remove any temporary reject or exception rules. Do not leave a test REJECT rule on a domain that needs to remain accessible.
For example, after setting an authorized test domain to REJECT, a new request to that destination should be rejected. However, old text may still appear from cache, and images loaded from other domains may remain visible. This illustrates a test method; it is not a report of results measured by this site. Check the corresponding request log rather than expecting the entire page to go blank immediately.
6. Shadowrocket rule-routing FAQs
I added FINAL,PROXY. Why are some requests still going direct?
First confirm Home → Global Routing → Config, then check whether a request matched an earlier DIRECT rule. FINAL applies only to requests that did not match anything before it. If earlier DOMAIN-SUFFIX, IP-CIDR, or GEOIP rules use DIRECT, check those lines rather than adding FINAL again.
Can I paste a full URL into DOMAIN-SUFFIX?
No. DOMAIN-SUFFIX does not take a full URL. Extract the hostname from https://api.example.com/login. To match only that host, use DOMAIN,api.example.com,PROXY. Use DOMAIN-SUFFIX,example.com,PROXY only when you need to match the root domain and its subdomains. Do not include the scheme, port, or path.
A request matches PROXY but the site will not open. Is the rule order wrong?
If the log shows the expected rule and PROXY, the routing decision is working. Next, check DNS resolution, whether the selected proxy is available, and the destination service’s status separately. A successful latency test only shows that the test received a response; it does not guarantee that the destination domain resolves or that the website is reachable.
Sign-in stopped working after I added REJECT. How do I fix it?
First remove the reject rule you just added, reconnect, and test again. If sign-in works, check whether the rejected domain hosts an authentication endpoint. Put a specific DOMAIN exception before the broader REJECT rule, or narrow the rejection condition. Do not reject an entire service’s root domain if you are unsure what depends on it.
When organizing a configuration, start with a small set of rules that explains each test result, then expand their scope gradually. For every new rule, you should be able to answer three questions: What does it match? Is there an earlier rule that could match first? Which policy applies if it matches? Once those points are clear, FINAL is simply an explicit choice at the end—not a patch for mistakes in earlier rules.
Get Shadowrocket and learn how to configure it
Two ways to get Shadowrocket: the iPhone and iPad app is a one-time $2.99 purchase on the App Store; check the App Store listing for system requirements. The Mac (Apple Silicon and Intel), Windows, Android, and Linux versions are free. Visit the download page to choose your platform, or follow the setup guide for configuration steps. This site does not provide, sell, or recommend nodes or subscriptions. Use a service you already have.