Shadowrocket Rules for Proxying Specific Websites: DOMAIN-SUFFIX Syntax and Order

Use DOMAIN-SUFFIX and DOMAIN-KEYWORD with FINAL,DIRECT to proxy only selected websites. Learn how rule order works and how to edit and test rules in Config.

At a glance

If you’ve already added a working server in Home and want only a few domains to use it, add PROXY rules for those domains in Config, then use FINAL,DIRECT for all other requests. This guide uses example domains to show how to keep direct-connection exceptions, avoid conflicts with older rules, and verify the results with two types of requests.

Choose the right match: hostname, domain suffix, or keyword

Rules match the destination of an individual request, not the full URL shown in the browser’s address bar. For https://docs.example.com/guide?lang=zh, for example, the value for a domain rule is docs.example.com—without https://, a path, query parameters, or a port. A page may also send requests to other hosts for images, login APIs, or downloads; each request is evaluated separately.

One hostname
DOMAIN matches an exact hostname, such as local.example.com
One domain suffix
DOMAIN-SUFFIX matches the domain and its subdomains
One fallback rule
FINAL,DIRECT handles requests that match no earlier rules

DOMAIN-SUFFIX,example.com,PROXY matches both example.com and docs.example.com. It won’t match notexample.com just because the name ends with the same characters. To proxy only docs.example.com, without including its subdomains, use DOMAIN,docs.example.com,PROXY. DOMAIN-KEYWORD matches a string anywhere in a hostname, potentially across multiple unrelated domains. If you only want to proxy a few known websites, list their domain suffixes individually.

Write the rules: put direct exceptions before proxy suffixes

The configuration below assumes that all of example.com should use the proxy, except for the local.example.com hostname, which must connect directly. The keyword rule demonstrates matching a group of hostnames that share a string; remove it if you don’t need that behavior. The example domains and expected matches illustrate rule syntax and don’t imply that these hosts serve real websites.

[Rule]
DOMAIN,local.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
DOMAIN-KEYWORD,docs-preview,PROXY
FINAL,DIRECT
Destination hostCheck rules in orderApply policyOutbound connection

Rules are evaluated from top to bottom. Once a rule matches, its policy applies and evaluation stops; later, more specific rules aren’t checked. So local.example.com uses DIRECT when it matches the first line. If you move that line below DOMAIN-SUFFIX, the suffix rule will send it to PROXY first. The first line exempts this hostname only. To exempt its subdomains too, change DOMAIN to DOMAIN-SUFFIX.

FINAL,DIRECT doesn’t override a proxy rule that matched earlier. If your existing configuration also contains rule sets, IP-CIDR, or GEOIP rules that send other destinations to PROXY, those requests may still use the proxy even when the last rule is DIRECT. To proxy only selected websites, review every rule in the full [Rule] section that could route traffic to PROXY—not just the last line.

Edit and enable rules in Config

  1. Keep a copy of the original configuration. In Config, check which configuration is currently in use, save a copy, then edit the local version. If the original file is updated from a remote URL, keep your custom rules in a local copy so an update won’t overwrite them. If you’re only changing routing, leave DNS and server settings alone; changing several things at once makes troubleshooting harder.
  2. Add the rules to the existing section. Find [Rule] and add the example rules there; don’t add a duplicate section header. Replace the example domains and direct-connection exception with your own, make sure there’s only one fallback rule, and place FINAL,DIRECT at the end of the section. Check each older rule you need to keep to ensure it doesn’t match your test domains first.
  3. Make sure the edited file is the one in use. Save the changes, select that configuration in Config, then go to Home → Global Routing → Config. The file you edited and the one currently in use must be the same. Proxy and Direct in Global Routing aren’t the rule mode needed here. If Scene is selected, switch to Config first so scene conditions don’t affect your test.
  4. Test with fresh requests. Make sure a working server is selected in Home and the connection is on. If a webpage or app was already transferring data before the changes, end the old session and reopen the test page. Change one rule at a time, and note the test hostname and actual outbound route so you can revert changes if needed.

Test routing with target and control domains

Choose a target that should use PROXY, an exception explicitly set to DIRECT, and an ordinary hostname that doesn’t appear in the rules. Check the destination host, matched rule, and outbound policy in the actual access log. A page loading successfully only shows that the request got a response; it doesn’t prove which route it took. A browser may also reuse cached data without sending a new request.

Expected routing for the example rules
Request hostExpected matchExpected policy
docs.example.comDOMAIN-SUFFIXPROXY
local.example.comDOMAINDIRECT
docs-preview.example.netDOMAIN-KEYWORDPROXY
example.orgFINALDIRECT

Opening a website that reports your exit IP only shows how that website’s own request was routed. With this configuration, if the IP-check site doesn’t match a proxy rule, a direct exit is expected; it doesn’t mean the target website also uses DIRECT. If a request matched PROXY but still won’t load, determine whether the connection to the server failed or the request to the destination website failed. Don’t change the fallback to PROXY just to clear an error.

Error: ERR_CONNECTION_TIMED_OUT

Cause: The browser timed out while waiting for a connection. The error alone can’t tell you whether the wrong policy was used or the selected route is unreachable. Fix: Check the outbound record for the request first. If it used PROXY, return to Home and run Connectivity Test for the selected server. Once the server connection is confirmed, retry the destination host.

Error: ERR_NAME_NOT_RESOLVED

Cause: The browser couldn’t resolve the hostname for this request. This commonly happens when the address is mistyped or the current resolution path can’t return a result. Fix: Check the address bar and the hostname recorded in the log, and make sure it’s a real, accessible domain. Then check whether that hostname resolves. Adding a domain rule can’t create a DNS record for a domain that doesn’t exist.

FAQs: Proxying specific websites

Why do login requests or images fail when the homepage loads?

Repeat the failed action and check the hostname and matched policy for that request. If the login API or images use a different domain and you’ve confirmed they also need the proxy, add a separate DOMAIN rule for that hostname before FINAL. Don’t add an entire shared resource domain to the proxy scope just to fix one login API.

Can I proxy just one directory on a domain?

These domain rules can’t distinguish between directories. Both example.com/docs and example.com/account have the hostname example.com; adding /docs to a DOMAIN-SUFFIX match value won’t match a path. If the service has a separate documentation subdomain, use DOMAIN to match that hostname exactly.

Why do other websites use the proxy when I set FINAL,DIRECT?

First, check whether Home → Global Routing is set to Config, then check which configuration is actually enabled in Config. Use a request that should connect directly to identify the first matching rule. If it matches an earlier rule set or an overly broad DOMAIN-KEYWORD rule, narrow that rule or remove it from your local copy, then test the same hostname again.

Download Shadowrocket