[GH-ISSUE #5572] [Bug]: Routing #3889

Closed
opened 2026-10-31 20:35:41 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @FPu3EpOBIIIuK on GitHub (Jun 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5572

Describe the bug

When specifying an IP address or domain, routing does not work.

How to reproduce the problem

  1. Add an outbound connection to another server, for example using the (vless) protocol, and name it, for instance, "Routing".
  2. Create a routing rule with the following parameters:

Domain: myip.com
Inbound tag: in-8888-tcp
Outbound tag: Routing

  1. Place it second in the list, after the rule with the API.

Expected behavior

It was assumed that when connected to in-8888-tcp and opening the website myip.com, the traffic would be routed through the outbound "Routing".

Actual behavior

When connected to in-8888-tcp and opening the website myip.com, the traffic goes directly to "direct".
However, if a user is specified instead of a domain, the traffic of that user connected through this inbound is successfully routed through the outbound "Routing".
I have also tried specifying, for example, geosite:YOUTUBE, but the issue persists.

Relevant logs

{
    "type": "field",
    "enabled": true,
    "domain": [
      "myip.com"
    ],
    "inboundTag": [
      "in-8888-tcp"
    ],
    "outboundTag": "Routing"
  }

Screenshots

No response

3x-ui version

3.4.0

Xray-core version

26.6.22

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @FPu3EpOBIIIuK on GitHub (Jun 25, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5572 ### Describe the bug When specifying an IP address or domain, routing does not work. ### How to reproduce the problem 1) Add an outbound connection to another server, for example using the (vless) protocol, and name it, for instance, "Routing". 2) Create a routing rule with the following parameters: Domain: myip.com Inbound tag: in-8888-tcp Outbound tag: Routing 3) Place it second in the list, after the rule with the API. ### Expected behavior It was assumed that when connected to in-8888-tcp and opening the website myip.com, the traffic would be routed through the outbound "Routing". ### Actual behavior When connected to in-8888-tcp and opening the website myip.com, the traffic goes directly to "direct". However, if a user is specified instead of a domain, the traffic of that user connected through this inbound is successfully routed through the outbound "Routing". I have also tried specifying, for example, geosite:YOUTUBE, but the issue persists. ### Relevant logs ```shell { "type": "field", "enabled": true, "domain": [ "myip.com" ], "inboundTag": [ "in-8888-tcp" ], "outboundTag": "Routing" } ``` ### Screenshots _No response_ ### 3x-ui version 3.4.0 ### Xray-core version 26.6.22 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:35:41 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 25, 2026):

The symptom — domain rules have no effect but user rules work — is the expected result when sniffing is disabled on the inbound. This is Xray-core behavior, not a 3x-ui bug.

Why user rules work but domain rules do not

When Xray receives a connection on in-8888-tcp, it knows the authenticated client identity (used by the user matcher) from the protocol handshake. It does not, however, know the requested domain unless sniffing is enabled. Without sniffing, the domain and geosite:* matchers in routing rules have nothing to match against, so the rule is skipped and traffic falls through to direct. The same applies to geosite:YOUTUBE.

Fix: enable sniffing on the inbound

  1. In the panel, open the inbound in-8888-tcp for editing.
  2. Go to the Sniffing tab.
  3. Toggle Enable on.
  4. Leave destOverride set to http, tls, quic (the defaults from frontend/src/schemas/primitives/sniffing.ts).
  5. Optionally enable Route Only (routeOnly: true) if you do not want Xray to rewrite the destination address — this is the right setting when the inbound is a proxy (VLESS/VMess/Trojan) that already carries the target domain in its own header.
  6. Save and apply.

After saving, the generated Xray config for that inbound will include a block such as:

"sniffing": {
  "enabled": true,
  "destOverride": ["http", "tls", "quic"],
  "routeOnly": false
}

With sniffing active, Xray extracts the SNI or HTTP Host for TLS/HTTP connections and populates the routing context with the domain, allowing "domain": ["myip.com"] and "geosite:YOUTUBE" rules to match.

Additional note on domainStrategy

The default Xray template shipped by 3x-ui (confirmed in internal/web/service/config.json) sets routing.domainStrategy to "AsIs". Under AsIs, Xray matches routing rules against the domain name extracted by sniffing; it does not perform DNS resolution to derive a domain from a raw IP. If the client connects by IP rather than hostname and sniffing cannot extract a domain, domain-based rules will still not match. If that scenario matters, you can change domainStrategy to "IPIfNonMatch" or "IPOnDemand" in Xray → Core Config.


This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4802863699 --> @github-actions[bot] commented on GitHub (Jun 25, 2026): The symptom — domain rules have no effect but user rules work — is the expected result when **sniffing is disabled** on the inbound. This is Xray-core behavior, not a 3x-ui bug. **Why user rules work but domain rules do not** When Xray receives a connection on `in-8888-tcp`, it knows the authenticated client identity (used by the `user` matcher) from the protocol handshake. It does not, however, know the requested domain unless sniffing is enabled. Without sniffing, the `domain` and `geosite:*` matchers in routing rules have nothing to match against, so the rule is skipped and traffic falls through to `direct`. The same applies to `geosite:YOUTUBE`. **Fix: enable sniffing on the inbound** 1. In the panel, open the inbound `in-8888-tcp` for editing. 2. Go to the **Sniffing** tab. 3. Toggle **Enable** on. 4. Leave `destOverride` set to `http`, `tls`, `quic` (the defaults from `frontend/src/schemas/primitives/sniffing.ts`). 5. Optionally enable **Route Only** (`routeOnly: true`) if you do not want Xray to rewrite the destination address — this is the right setting when the inbound is a proxy (VLESS/VMess/Trojan) that already carries the target domain in its own header. 6. Save and apply. After saving, the generated Xray config for that inbound will include a block such as: ```json "sniffing": { "enabled": true, "destOverride": ["http", "tls", "quic"], "routeOnly": false } ``` With sniffing active, Xray extracts the SNI or HTTP `Host` for TLS/HTTP connections and populates the routing context with the domain, allowing `"domain": ["myip.com"]` and `"geosite:YOUTUBE"` rules to match. **Additional note on `domainStrategy`** The default Xray template shipped by 3x-ui (confirmed in `internal/web/service/config.json`) sets `routing.domainStrategy` to `"AsIs"`. Under `AsIs`, Xray matches routing rules against the domain name extracted by sniffing; it does not perform DNS resolution to derive a domain from a raw IP. If the client connects by IP rather than hostname and sniffing cannot extract a domain, domain-based rules will still not match. If that scenario matters, you can change `domainStrategy` to `"IPIfNonMatch"` or `"IPOnDemand"` in **Xray → Core Config**. --- *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@FPu3EpOBIIIuK commented on GitHub (Jun 25, 2026):

I configured it according to your instructions, everything worked as expected. Thank you for the detailed and prompt response.

<!-- gh-comment-id:4802929854 --> @FPu3EpOBIIIuK commented on GitHub (Jun 25, 2026): I configured it according to your instructions, everything worked as expected. Thank you for the detailed and prompt response.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3889
No description provided.