Skip to content

Routing in 3x-ui: choose where traffic goes

Created: November 23, 2026.

The examples use the cascade's standard rules and 3x-ui routing forms. The main forms were checked against the 3.12.0 source code on November 30, 2026. Verify the resulting route with a real connection.

What routing does and what you will learn

When your phone connects to your VPS, that does not yet determine which server will send the request to the website. An inbound accepts traffic from your device. An outbound either sends it directly to the internet or forwards it elsewhere, such as another VPS. A routing rule selects the appropriate exit.

Phone → REALITY/XHTTP inbound on VPS → Xray rules
                                        ├─ direct → Internet from this VPS
                                        ├─ blocked → request blocked
                                        └─ backup-se → Second VPS → Internet

This guide explains the rules provided by our cascade and lets you jump straight to the example you need:

If you are configuring routes for the first time, read how rule priority works first.

The following examples are independent. For examples using backup-se, first add an outbound connection and test it over HTTP. Changing CASCADE - EXIT requires an existing cascade. All tags below are examples; select the values that exist in your panel.

1. How our cascade routes traffic by default

When you connect a cascade using the 3X-UI AUTO NGINX manager, the entry server automatically gets the cascade-exit outbound and three rules under Xray → Routing → Routing:

Rule What matches Destination
CASCADE - RU Domains in geosite:category-ru direct
CASCADE - RU2 Destination IPs in geoip:ru direct
CASCADE - EXIT TCP and UDP if previous rules did not match cascade-exit

Why is it configured this way? Russian resources can usually be reached directly from a Russian entry VPS without sending a request to Europe and back. This avoids an unnecessary detour and preserves a Russian exit IP for relevant resources. Other matching traffic goes to the VPS abroad. This is the default behavior, not a restriction on custom settings.

Request to a Russian domain/IP → CASCADE - RU / RU2 → direct
Other matching request         → CASCADE - EXIT     → VPS abroad

geosite:category-ru and geoip:ru are sets of domains and IP ranges in Xray's geodata. They do not know a website's nationality and do not cover every resource perfectly. What matters is the actual destination domain or IP and the availability of matching data.

The normal cascade route does not send literally everything through Europe

The Russian exceptions are above CASCADE - EXIT, so they match first. The panel's service rules and your custom rules may also appear earlier. Do not remove service rules for api and internal addresses.

2. Rule priority: the first match wins

Xray evaluates enabled rules from top to bottom. As soon as a rule's conditions match, the selected outbound or balancer is used. Rules below it no longer apply to that connection.

  • Different condition types in one rule (for example User and Domain) must match simultaneously. This is useful for restricting a rule to one client.
  • Multiple values in one field (for example two domains) match any qualifying value.
  • Place specific rules above broad ones: a YouTube rule goes above CASCADE - EXIT; a block for one user goes above the broad CASCADE - RU and CASCADE - RU2 rules.
  • If no rule matches, Xray uses its default route. Do not rely on that accidentally: the order of outbounds in the configuration matters too.

On Xray → Routing, open the Routing tab with the rule list. The add button is above the table; the pencil icon edits an existing rule. Change the order by dragging rules or using the move commands. After editing, click Save on the main Xray page.

To check a new rule, use the adjacent route-testing tab and then verify an actual request from a connected device. Testing route selection and checking the exit IP answer different questions.

Remember to save the working configuration

Before changing routing, make a backup of your settings. A new route may briefly interrupt connections. If the result is unexpected, restore the previous value or disable the new rule, then save Xray again.

3. Example: route only YouTube through a second server

Result: YouTube goes through backup-se, while other websites retain their previous routes. You need a working backup-se outbound; an existing cascade is optional.

Value for the Domain field (use the copy button):

geosite:youtube
  1. Make sure the backup-se outbound exists and passes the HTTP test.
  2. On the entry VPS, open Xray → Routing, then the tab containing the rule list.
  3. Click the add-rule button.
  4. In the Remarks field, enter YouTube via backup.
  5. Paste geosite:youtube from the block above into the Domain field. This is a set of YouTube and related domains, not just youtube.com.
  6. In Outbound tag (outboundTag), select backup-se. Leave Balancer tag empty.
  7. Leave all other conditions empty, enable the rule and create it.
  8. Move it above broad rules that could catch the request. If Cascade is configured, place it above CASCADE - RU, CASCADE - RU2 and CASCADE - EXIT. Do not delete service rules.
  9. Click the main Save button for Xray.

Check the route for a hostname such as www.youtube.com, then open a video from a device connected to the entry VPS. For domain matching, Xray must know the domain name: it can obtain it from the proxy request or through sniffing (detecting the domain from connection data), if enabled. If an app connects using only an IP address and Xray does not know the domain, a geosite rule may not match.

Rollback: disable or delete only YouTube via backup, then save the configuration.

4. Example: route all ordinary traffic through a selected server

Result: user connection traffic that is not caught by earlier service or specific rules exits through backup-se.

This example assumes a working cascade with the CASCADE - EXIT rule and a verified backup-se outbound. Do not create a second broad rule. Use the existing one:

  1. Open Xray → Routing → Routing on the entry VPS.
  2. Find CASCADE - EXIT. Note its current outbound tag and the enabled states of CASCADE - RU and CASCADE - RU2 so you can restore them if needed. Click the pencil icon.
  3. Change Outbound tag from cascade-exit to backup-se. Leave the balancer empty.
  4. Save the rule.
  5. If you also need Russian websites to exit through backup-se, disable CASCADE - RU and CASCADE - RU2 using their switches. This may break access to sites that require a Russian IP. If you want to keep the previous Russian exceptions, leave their states unchanged.
  6. Click the main Save button.

This redirects the general route without changing inbound profiles or clients. Disabling the two Russian rules also affects Russian resources, so sites requiring a Russian IP may no longer work as before.

Do not delete cascade-exit, Xray service rules or the cascade client on the VPS abroad: they belong to the existing cascade configuration. The cascade manager may still consider the entry role configured. Before disabling Cascade through the manager later, check custom routes and dependencies.

Verification: from a device actually using the entry VPS, open an IP-checking website. If backup-se uses direct egress, it should show the public IP of the second server (provided it does not use additional WARP or a proxy). For every tested website, take into account rules above CASCADE - EXIT.

Rollback: restore the previous outbound tag in CASCADE - EXIT and the original enabled states of CASCADE - RU and CASCADE - RU2, then save.

5. Example: block Russian resources for one client

Result: Russian domains and IPs are blocked for the selected client, while other clients continue using their existing rules. A cascade and a second VPS are optional. If there is no cascade, place the new rules above broad rules that could otherwise handle this traffic.

You will need the client email within 3x-ui (the user identifier for Xray rules), not the web panel login. Suppose the client's email is example-client.

Create two separate rules and place them above the broad routes (for a cascade, above CASCADE - RU, CASCADE - RU2 and CASCADE - EXIT):

Field Rule 1 Rule 2
Remarks Block RU domains for client Block RU IP for client
User (user) example-client example-client
Domain geosite:category-ru leave empty
IP leave empty geoip:ru
Outbound tag blocked blocked
  1. On the VPS the client connects to, open Xray → Routing → Routing and click the add-rule button.
  2. Select the appropriate client in the User field (the panel may display a list of email identifiers).
  3. Fill in the fields from the Rule 1 column, leave other conditions empty, enable and create the rule.
  4. Create the second rule using the Rule 2 column, selecting the same user and blocked outbound.
  5. Move both rules above the broad cascade rules (or other broad rules if there is no cascade), without deleting service rules, and click the main Save button.

Why two rules? If both domain and ip are filled in one rule, Xray looks for a connection satisfying both conditions. Two rules cover separate cases. Geodata-based blocking does not block every website associated with Russia: a domain may be missing from the list or resolve to an IP abroad.

Verification: open a matching resource through the example-client profile, then repeat with another client. The second client should not be affected by these restrictions. If the rule unexpectedly applies to everyone, check that the User field is not empty.

Rollback: disable both added rules and save Xray.

6. Example: route an XHTTP inbound through a second server

Result: connections received through the selected XHTTP inbound exit through backup-se, while the other REALITY and Hysteria2 inbounds retain their routes. You need a separate XHTTP inbound and a verified backup-se outbound; an existing cascade is optional.

Be careful with multiple transports: inboundTag distinguishes inbounds, not necessarily individual transports within one inbound. If one inbound accepts traffic in several ways, the rule affects the entire inbound, not only XHTTP. First confirm that the tag belongs to the separate inbound you need.

  1. On the entry VPS, open Inbounds and edit the relevant VLESS XHTTP connection.
  2. Find and copy its exact inbound tag (inboundTag). Do not confuse it with a client name, a port or the network field.
  3. Open Xray → Routing → Routing and create a rule.
  4. Enter XHTTP via backup in the Remarks field.
  5. In Inbound tags (inboundTag), select the XHTTP tag you found.
  6. In Outbound tag, choose backup-se. Leave all other conditions empty.
  7. Move the rule above broad routes that could catch XHTTP traffic, including cascade rules if configured. Enable the rule and click the main Save button.

Verification: connect from your device using the XHTTP profile and check the public IP. Then repeat using a different inbound. The second should retain its original route unless another rule changes it.

Rollback: disable XHTTP via backup and save Xray.

What else routing affects

  • direct and blocked are outbounds too. The first sends traffic directly from the current VPS; the second rejects it.
  • Leave service rules alone. In particular, the api rule is required by the panel, and blocking private IPs prevents unwanted connections to internal addresses.

If you need to switch automatically to a backup VPS when the primary exit fails, rather than manually selecting one exit, follow the balancer guide. There, the existing CASCADE - EXIT rule uses a balancer tag instead of a direct outbound tag.


Add an outbound server · Backup server for a cascade · Cascade across two VPS instances

Attribution and use of materials

© 2026 xPROMSx contributors · 3X-UI AUTO NGINX

Our material may be copied and distributed under the GNU GPL-3.0-only license, provided the attribution and link to the original are retained.

Original source: https://xpromsx.github.io/3x-ui-auto-nginx/guides/routing/

Terms of use for project materials