If you already use a Shadowrocket configuration for traffic routing and want to block a domain or troubleshoot an unexpected block, first confirm the connection is on, Home → Global Routing is set to Config, and the active configuration is selected on the Config screen. Domain rules match hostnames, not full URLs. A rule rejects traffic only when it passes through the client, the relevant hostname is available for matching, and that rule is the first match and uses REJECT.
REJECT is an action, not a match condition
In DOMAIN-SUFFIX,blocked.example.com,REJECT, the first field is the rule type, the second defines what it matches, and the third is the action taken when it matches. REJECT doesn’t look up domains or change earlier rules. It rejects traffic assigned to that action; it doesn’t send it to DIRECT or PROXY.
Rules in the current configuration’s [Rule] section are evaluated in order; a more specific domain doesn’t automatically take priority. Suppose DOMAIN-SUFFIX,example.com,DIRECT appears above a blocking rule. A request to blocked.example.com will match the broader DIRECT rule first, so the REJECT below it won’t apply. To keep blocking that subdomain, put the narrower rule before the broader one and check for any other matching rules above it.
Check rules under Home → Global Routing → Config. Don’t use page loading under global Proxy or Direct to infer how [Rule] behaves. If you normally use Scene, note your current settings, switch to Config to establish a test baseline, then restore your settings if needed. An enabled connection only means the connection is active; it doesn’t show that a particular domain rule matched.
DOMAIN-SUFFIX vs. DOMAIN-KEYWORD: matching scope
When you know the target hostname, prefer a narrow DOMAIN-SUFFIX. To match one exact hostname, you can also use DOMAIN. Use DOMAIN-KEYWORD only when you intentionally want to match a character sequence shared by multiple domains. The examples below use reserved example domains to illustrate rule behavior; they don’t imply that these hosts serve actual websites.
Domain matching examples
DOMAIN-SUFFIX: domain suffix
- Match value
blocked.example.com- Matches the domain itself
blocked.example.com- Matches subdomains
img.blocked.example.com- Doesn’t match
notblocked.example.com
Matches at domain-label boundaries; a similar string at the end of a hostname isn’t necessarily the same domain suffix.
DOMAIN-KEYWORD: substring in a hostname
- Match value
telemetry- Matches a complete label
telemetry.example.com- Matches within a label
nottelemetry.example.net- Doesn’t match URL paths
https://example.com/telemetry
Searches for a substring in the hostname only; it doesn’t require a domain-label boundary or inspect the URL path.
When you take a rule value from a URL, use only the hostname. For example, the hostname in https://blocked.example.com:443/assets/logo.svg?size=2 is blocked.example.com. Don’t include https://, the port, path, or query parameters in the rule. There’s no need to write a suffix rule as *.blocked.example.com; the suffix alone matches the domain and its subdomains.
The order below is illustrative, not a complete configuration. If a parent-domain rule already exists, insert the narrower blocking rule above it. Don’t add a parent-domain DIRECT rule just to test, and don’t change the existing FINAL rule. FINAL handles traffic that didn’t match an earlier rule; changing it would affect two parts of the comparison.
[Rule]
DOMAIN-SUFFIX,blocked.example.com,REJECT
DOMAIN-SUFFIX,example.com,DIRECT
Limits of domain rules: shared hosts, HTTPS, and direct IP connections
Domain rules can distinguish hostnames, but not different types of content hosted on the same hostname. Even for unencrypted requests, DOMAIN-SUFFIX and DOMAIN-KEYWORD match only domains; paths aren’t inputs to either rule. If a login request and a request you want to block use the same hostname, a REJECT rule for that domain affects both. It can’t allow one path while blocking another.
| Request scenario | How domain rules behave | What to check |
|---|---|---|
| Different hostnames | When the target domains are visible, you can handle each hostname separately. | Check that both hostnames don’t fall under the same blocked suffix. |
| Same hostname, different paths | Can’t distinguish /login from /events by path. | Compare the full URLs to see whether the difference is only in the path or query parameters. |
| HTTPS requests | Domain matching still works when the target domain is available; that doesn’t mean encrypted request contents can be read. | Seeing port 443 alone doesn’t identify the target hostname. |
| IP address only | Without usable domain information, domain suffix and substring matching aren’t possible. | First determine whether the connection directly targets an IP or a domain connection was logged with its destination IP. |
The domain in a browser’s address bar isn’t necessarily the target of a particular connection. A page may also request images or API calls from other hosts, or follow a redirect to a new host. Encrypted DNS or an encrypted handshake can affect which domain information the client can obtain for a given connection, but that doesn’t mean HTTPS domains can never be matched. If a log shows only an IP, don’t immediately add it to an IP-CIDR blocking rule: multiple domains can share an address, and a domain’s address can change. Identify the actual request target first, then decide whether a domain rule is appropriate.
Verify a rule match and check for unintended blocks
For testing, choose two requests that both worked before the change: one to a target hostname you’re authorized to test, and one to a control hostname that shouldn’t be blocked. Don’t use an address that was already unreachable to test the blocking result. Change one rule at a time and keep the network, routing mode, and other rules unchanged so you can attribute the result to that configuration change.
- Record what happens before the change. On Home, confirm the connection is on and Global Routing is set to Config. Make the target request and the control request separately, then note each hostname and whether it loads. Don’t record only whether the page opens: if the request you want to block is embedded in a page, a successful page load doesn’t mean that request succeeded.
- Edit the active configuration. On the Config screen, confirm which configuration is in use. Add a narrow
REJECTrule for the target hostname above any broader rule that would match it. After saving, confirm the active configuration contains the rule so you don’t accidentally edit an unused copy. - Start a new connection. End the existing session in the test app, then reopen it and make the request again. Cached page content can persist, and existing connections don’t show whether a new rule matched. If connection records show the applied action, check the target hostname and timestamp for this test request.
- Compare the results, then test without the rule. The expected result is that the target request fails while the control request still succeeds. The app may show a loading error or switch to a backup host. Temporarily remove the new rule and try again. If the target still fails, check the network, target service, or other rules instead of attributing every error to
REJECT.
FAQ: Did the rule fail, or is it blocking too much?
Why does the website still load after I added a REJECT rule?
First, go to Home → Global Routing and confirm Config is selected. Then check the active configuration and rule order on the Config screen. Next, make sure you’re opening the blocked hostname itself, not another page that references it. If the target is just an API request on a page, the expected result is for that request to fail—not for the entire page to become inaccessible.
Why does blocking one API request also break login?
Compare the hostnames used by the API request and login. If they differ only by path, remove the domain blocking rule; changing rule order won’t make a domain rule distinguish paths. If they use different subdomains, replace the parent-domain suffix with the target subdomain. If you need to match only that exact hostname, you can use DOMAIN. Then test login and the API request separately.
Why did other websites stop loading after I used DOMAIN-KEYWORD?
Disable the new keyword rule and test again. If access returns, check the hostnames of affected requests to see whether the keyword also appears in unrelated domains. If you know the target hostname, replace the keyword with an exact DOMAIN or the narrowest suitable DOMAIN-SUFFIX, then retest the target and the affected websites.
Why did a request start getting through after I updated the configuration?
On the Config screen, compare the active configuration with the copy saved before the update. Check whether your custom rule is still there, whether a broader rule was added above it, and whether the same configuration is still active. Restore and test the individual rule before deciding how to keep local changes. There’s no need to change FINAL or replace the entire [Rule] section first.