[GH-ISSUE #4848] [Question]: Global Xray settings (DNS, Routing, domainStrategy) are not reflected in generated client subscription configs #3378

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

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

What are you trying to do?

I want my clients to automatically inherit the global Xray settings configured in the panel when they update their subscription.

Specifically, I have configured custom DNS servers (Cloudflare), routing strategies (IPIfNonMatch), and IPv4 preferences (UseIPv4) in the panel. However, when a client imports the subscription into their application (e.g., Happ / Hiddify), these settings are missing or overwritten by defaults (Google DNS, AsIs strategy).

I am trying to understand if client subscriptions are intentionally generated using an independent hardcoded template, or if there is a way to make them inherit the panel's global Xray configuration.

What have you already tried?

  • Checked the panel's "Xray Configuration" and confirmed that the settings are saved and working correctly on the server side.
  • Inspected the generated client JSON config inside the app and compared it with the panel's config.
  • Searched the Wiki and open/closed issues regarding subscription templates or global setting inheritance but couldn't find a clear answer.

3x-ui version

3.2.6

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 26.04

Screenshots or config snippets

Here is the comparison between what is configured in the panel and what the client actually receives via the subscription link.

  1. Panel Xray Configuration (Server Side)

Global DNS & Routing:

{
  "routing": {
    "domainStrategy": "IPIfNonMatch"
  },
  "dns": {
    "servers": [
      "1.1.1.1",
      "1.0.0.1",
      "2606:4700:4700::1111",
      "2606:4700:4700::1001"
    ],
    "queryStrategy": "UseIPv4"
  }
}

Outbound Freedom & Inbound Sockopt:
{
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "UseIPv4"
      }
    }
  ],
  "sockopt": {
    "domainStrategy": "UseIPv4"
  }
}

Generated Client Configuration (Happ / Hiddify)

DNS becomes Google instead of Cloudflare, and strategy resets to UseIP:
"dns": {
    "queryStrategy": "UseIP",
    "servers": [
        {
            "address": "8.8.8.8",
            "skipFallback": false
        }
    ],
    "tag": "dns_out"
}

Routing and Freedom outbound strategies reset to AsIs:
"routing": {
    "domainStrategy": "AsIs"
},
"outbounds": [
    {
        "protocol": "freedom",
        "settings": {
            "domainStrategy": "AsIs"
        },
        "tag": "direct"
    }
]

Questions:
- Is it expected behavior that generated subscriptions do not inherit these global parameters?
- If it is intentional, is there a template file or a specific place in the panel where I can modify the default settings for all generated client configs?

### Before submitting

- [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue).
- [x] This is a usage question, not a bug report.
- [x] This question is written in English.
Originally created by @rusik-afk on GitHub (Jun 3, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4848 ### What are you trying to do? I want my clients to automatically inherit the global Xray settings configured in the panel when they update their subscription. Specifically, I have configured custom DNS servers (Cloudflare), routing strategies (IPIfNonMatch), and IPv4 preferences (UseIPv4) in the panel. However, when a client imports the subscription into their application (e.g., Happ / Hiddify), these settings are missing or overwritten by defaults (Google DNS, AsIs strategy). I am trying to understand if client subscriptions are intentionally generated using an independent hardcoded template, or if there is a way to make them inherit the panel's global Xray configuration. ### What have you already tried? - Checked the panel's "Xray Configuration" and confirmed that the settings are saved and working correctly on the server side. - Inspected the generated client JSON config inside the app and compared it with the panel's config. - Searched the Wiki and open/closed issues regarding subscription templates or global setting inheritance but couldn't find a clear answer. ### 3x-ui version 3.2.6 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 26.04 ### Screenshots or config snippets Here is the comparison between what is configured in the panel and what the client actually receives via the subscription link. 1. Panel Xray Configuration (Server Side) Global DNS & Routing: ```json { "routing": { "domainStrategy": "IPIfNonMatch" }, "dns": { "servers": [ "1.1.1.1", "1.0.0.1", "2606:4700:4700::1111", "2606:4700:4700::1001" ], "queryStrategy": "UseIPv4" } } Outbound Freedom & Inbound Sockopt: { "outbounds": [ { "tag": "direct", "protocol": "freedom", "settings": { "domainStrategy": "UseIPv4" } } ], "sockopt": { "domainStrategy": "UseIPv4" } } Generated Client Configuration (Happ / Hiddify) DNS becomes Google instead of Cloudflare, and strategy resets to UseIP: "dns": { "queryStrategy": "UseIP", "servers": [ { "address": "8.8.8.8", "skipFallback": false } ], "tag": "dns_out" } Routing and Freedom outbound strategies reset to AsIs: "routing": { "domainStrategy": "AsIs" }, "outbounds": [ { "protocol": "freedom", "settings": { "domainStrategy": "AsIs" }, "tag": "direct" } ] Questions: - Is it expected behavior that generated subscriptions do not inherit these global parameters? - If it is intentional, is there a template file or a specific place in the panel where I can modify the default settings for all generated client configs? ### Before submitting - [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue). - [x] This is a usage question, not a bug report. - [x] This question is written in English.
bsakaguchi 2026-10-31 20:32:01 +07:00
Author
Owner

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

Yes — this is by design, and here is exactly why

The JSON subscription endpoint (/sub/json/<subId>) generates client configs from a hardcoded embedded template: sub/default.json. That template is compiled directly into the binary via //go:embed default.json in sub/subJsonService.go and is not derived from the server-side Xray configuration at all.

The template hardcodes the following client defaults, regardless of what you have set in the panel's "Xray Configuration":

Field Hardcoded value in sub/default.json
dns.queryStrategy "UseIP"
dns.servers[0].address "8.8.8.8" (Google DNS)
routing.domainStrategy "AsIs"
freedom outbound domainStrategy "AsIs"

This separation is intentional: your server-side settings (e.g. UseIPv4, Cloudflare DNS) control how the server routes outbound traffic, while the subscription template controls how the client app connects. Pushing server routing policy to every client app would often break clients on different networks.

What the panel does let you customise per client config

The subscription server reads four configurable fields from panel settings (Panel → Subscription → JSON settings):

Setting key What it controls in the generated client JSON
subJsonFragment Adds a fragment config to the direct_out freedom outbound
subJsonNoises Adds noises to the same freedom outbound
subJsonMux Adds a mux block to every proxy outbound
subJsonRules Prepends extra routing rules to the default rule list

Crucially, there are no panel settings for dns.servers, dns.queryStrategy, or routing.domainStrategy in client configs. Those are fixed in sub/default.json.

What you can do right now

Option 1 – Custom routing rules (partial help): The subJsonRules panel setting lets you add rules (e.g. bypass Iran/China IPs via direct) to every generated client config. It will not change DNS servers or domainStrategy, but covers the routing-rules use case.

Option 2 – Build from source with a patched sub/default.json: If you self-host and can build the binary, you can edit sub/default.json to change the default DNS servers and domain strategies before compiling. This is the only current path to a different hardcoded default.

Option 3 – Request the feature: If you'd like the panel to expose DNS and domainStrategy as configurable subscription settings (similar to how subJsonRules works), that would be a reasonable enhancement request. You could open a new issue with the enhancement / New Feature label describing exactly which fields you want to be configurable.

Summary

Is it expected behavior that generated subscriptions do not inherit these global parameters?

Yes. The client JSON subscription is generated from a fixed embedded template (sub/default.json), not from the server-side Xray config. The two configs are intentionally independent.

Is there a template file or a specific place in the panel where I can modify the default settings for all generated client configs?

The source file is sub/default.json. There is no panel UI to modify it at runtime — it would need to be changed before building the binary (or the feature would need to be added to the panel).

<!-- gh-comment-id:4610694737 --> @github-actions[bot] commented on GitHub (Jun 3, 2026): ## Yes — this is by design, and here is exactly why The JSON subscription endpoint (`/sub/json/<subId>`) generates client configs from a **hardcoded embedded template**: [`sub/default.json`](https://github.com/MHSanaei/3x-ui/blob/main/sub/default.json). That template is compiled directly into the binary via `//go:embed default.json` in `sub/subJsonService.go` and is **not derived from the server-side Xray configuration** at all. The template hardcodes the following client defaults, regardless of what you have set in the panel's "Xray Configuration": | Field | Hardcoded value in `sub/default.json` | |---|---| | `dns.queryStrategy` | `"UseIP"` | | `dns.servers[0].address` | `"8.8.8.8"` (Google DNS) | | `routing.domainStrategy` | `"AsIs"` | | freedom outbound `domainStrategy` | `"AsIs"` | This separation is intentional: your server-side settings (e.g. `UseIPv4`, Cloudflare DNS) control how **the server routes outbound traffic**, while the subscription template controls how **the client app** connects. Pushing server routing policy to every client app would often break clients on different networks. ## What the panel *does* let you customise per client config The subscription server reads four configurable fields from panel settings (Panel → Subscription → JSON settings): | Setting key | What it controls in the generated client JSON | |---|---| | `subJsonFragment` | Adds a `fragment` config to the `direct_out` freedom outbound | | `subJsonNoises` | Adds `noises` to the same freedom outbound | | `subJsonMux` | Adds a `mux` block to every proxy outbound | | `subJsonRules` | **Prepends** extra routing `rules` to the default rule list | Crucially, there are **no panel settings** for `dns.servers`, `dns.queryStrategy`, or `routing.domainStrategy` in client configs. Those are fixed in `sub/default.json`. ## What you can do right now **Option 1 – Custom routing rules (partial help):** The `subJsonRules` panel setting lets you add rules (e.g. bypass Iran/China IPs via `direct`) to every generated client config. It will not change DNS servers or domainStrategy, but covers the routing-rules use case. **Option 2 – Build from source with a patched `sub/default.json`:** If you self-host and can build the binary, you can edit `sub/default.json` to change the default DNS servers and domain strategies before compiling. This is the only current path to a different hardcoded default. **Option 3 – Request the feature:** If you'd like the panel to expose DNS and domainStrategy as configurable subscription settings (similar to how `subJsonRules` works), that would be a reasonable enhancement request. You could open a new issue with the `enhancement` / `New Feature` label describing exactly which fields you want to be configurable. ## Summary > Is it expected behavior that generated subscriptions do not inherit these global parameters? **Yes.** The client JSON subscription is generated from a fixed embedded template (`sub/default.json`), not from the server-side Xray config. The two configs are intentionally independent. > Is there a template file or a specific place in the panel where I can modify the default settings for all generated client configs? The source file is `sub/default.json`. There is no panel UI to modify it at runtime — it would need to be changed before building the binary (or the feature would need to be added to the panel).
Author
Owner

@MHSanaei commented on GitHub (Jun 12, 2026):

Closing as a duplicate of #4850, which tracks the same request (panel settings to customize DNS / queryStrategy / domainStrategy for generated client subscription configs). Let''s consolidate the discussion there.

<!-- gh-comment-id:4686428893 --> @MHSanaei commented on GitHub (Jun 12, 2026): Closing as a duplicate of #4850, which tracks the same request (panel settings to customize DNS / queryStrategy / domainStrategy for generated client subscription configs). Let''s consolidate the discussion there.
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#3378
No description provided.