[GH-ISSUE #4941] [Feature]: How to customize Clash subscription proxy groups in 3x-ui / Issue with "Happ only" routing rule #3461

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

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

I am trying to configure the Clash subscription feature in 3x-ui, specifically regarding how to use and customize the proxy groups (Proxy Providers).

Although I have enabled the routing features, the configuration notes indicate that it is "Happ only" (restricted to Happ). I would like to know how to further modify or extend this setup so it can work with other clients or customized routing rules.

Could anyone guide me on how to properly modify the template or configuration to achieve this? Thanks!

Describe the solution you'd like

"Hey guys, quick question about 3x-ui's Clash subscription feature. I see the routing is enabled but it says 'Happ only'. How can I modify the proxy groups and routing rules so they aren't restricted to just Happ? Any tips on where to edit the config template?"

Alternatives you've considered

No response

Concrete use case

No response

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

No response

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @yifeng623 on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4941 I am trying to configure the Clash subscription feature in 3x-ui, specifically regarding how to use and customize the proxy groups (Proxy Providers). Although I have enabled the routing features, the configuration notes indicate that it is "Happ only" (restricted to Happ). I would like to know how to further modify or extend this setup so it can work with other clients or customized routing rules. Could anyone guide me on how to properly modify the template or configuration to achieve this? Thanks! ### Describe the solution you'd like "Hey guys, quick question about 3x-ui's Clash subscription feature. I see the routing is enabled but it says 'Happ only'. How can I modify the proxy groups and routing rules so they aren't restricted to just Happ? Any tips on where to edit the config template?" ### Alternatives you've considered _No response_ ### Concrete use case _No response_ ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? _No response_ ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [ ] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

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

There are two separate routing systems in the panel's subscription settings, and the "Happ only" note only applies to one of them.

The "Happ only" section (not what you want for Clash)

In Panel Settings → Subscription → Happ, there are two fields:

  • Enable Routing (subEnableRouting) — emits a Routing-Enable: true HTTP response header
  • Routing Rules (subRoutingRules) — emits a Routing: ... HTTP response header (placeholder shows happ://routing/add/...)

These are HTTP headers only. They are sent on every subscription response (base64 links, JSON, and Clash alike) but only the Happ client actually reads and acts on them. That's why they're labelled "Happ only" — other clients ignore those headers entirely. The comment in the source (web/entity/entity.go:66) confirms: // Subscription global routing rules (Only for Happ).

The Clash/Mihomo routing section (what you want)

Right below the Happ section in Panel Settings → Subscription → Clash / Mihomo, there are two different fields:

  • Clash Enable Routing (subClashEnableRouting) — toggle this on
  • Clash Routing Rules (subClashRules) — paste your YAML rules here

When a Clash subscription is fetched, the backend (sub/subClashService.go) calls mergeClashRulesYAML to inject those rules into the generated YAML before serving it. The UI placeholder shows the expected format:

GEOSITE,category-ir,DIRECT
GEOIP,private,DIRECT

You can also pass a YAML block with a rules: key. If your rules include a MATCH,... line, it replaces the default MATCH,PROXY catch-all; otherwise your rules are prepended before it.

Example to bypass Iranian sites directly:

rules:
  - GEOSITE,category-ir,DIRECT
  - GEOIP,ir,DIRECT
  - MATCH,PROXY

Proxy-groups customization

The generated Clash config currently hardcodes a single select-type group named PROXY (sub/subClashService.go:77-83). The subClashRules field only merges into the rules: list — there is no UI field for custom proxy-groups:. If you need load-balancing, fallback, or url-test groups, that would require a new feature (a custom proxy-groups template field similar to subClashRules). Feel free to keep this issue open as a feature request for that, or submit a PR.

<!-- gh-comment-id:4627744606 --> @github-actions[bot] commented on GitHub (Jun 5, 2026): There are **two separate routing systems** in the panel's subscription settings, and the "Happ only" note only applies to one of them. ## The "Happ only" section (not what you want for Clash) In **Panel Settings → Subscription → Happ**, there are two fields: - **Enable Routing** (`subEnableRouting`) — emits a `Routing-Enable: true` HTTP response header - **Routing Rules** (`subRoutingRules`) — emits a `Routing: ...` HTTP response header (placeholder shows `happ://routing/add/...`) These are *HTTP headers only*. They are sent on every subscription response (base64 links, JSON, and Clash alike) but only the Happ client actually reads and acts on them. That's why they're labelled "Happ only" — other clients ignore those headers entirely. The comment in the source ([`web/entity/entity.go:66`](../blob/main/web/entity/entity.go#L66)) confirms: `// Subscription global routing rules (Only for Happ)`. ## The Clash/Mihomo routing section (what you want) Right below the Happ section in **Panel Settings → Subscription → Clash / Mihomo**, there are two different fields: - **Clash Enable Routing** (`subClashEnableRouting`) — toggle this on - **Clash Routing Rules** (`subClashRules`) — paste your YAML rules here When a Clash subscription is fetched, the backend ([`sub/subClashService.go`](../blob/main/sub/subClashService.go)) calls `mergeClashRulesYAML` to inject those rules into the generated YAML before serving it. The UI placeholder shows the expected format: ``` GEOSITE,category-ir,DIRECT GEOIP,private,DIRECT ``` You can also pass a YAML block with a `rules:` key. If your rules include a `MATCH,...` line, it replaces the default `MATCH,PROXY` catch-all; otherwise your rules are prepended before it. **Example** to bypass Iranian sites directly: ```yaml rules: - GEOSITE,category-ir,DIRECT - GEOIP,ir,DIRECT - MATCH,PROXY ``` ## Proxy-groups customization The generated Clash config currently hardcodes a single `select`-type group named `PROXY` ([`sub/subClashService.go:77-83`](../blob/main/sub/subClashService.go#L77-L83)). The `subClashRules` field only merges into the `rules:` list — there is no UI field for custom `proxy-groups:`. If you need load-balancing, fallback, or url-test groups, that would require a new feature (a custom proxy-groups template field similar to `subClashRules`). Feel free to keep this issue open as a feature request for that, or submit a PR.
Author
Owner

@yifeng623 commented on GitHub (Jun 5, 2026):

Thanks for the detailed breakdown! However, looking at my panel (as shown in the screenshot ), there is actually no Clash/Mihomo section available at all. The UI cuts off right after the Happ section.

Image
<!-- gh-comment-id:4627774888 --> @yifeng623 commented on GitHub (Jun 5, 2026): Thanks for the detailed breakdown! However, looking at my panel (as shown in the screenshot ), there is actually no Clash/Mihomo section available at all. The UI cuts off right after the Happ section. <img width="1537" height="654" alt="Image" src="https://github.com/user-attachments/assets/c9efaca5-1f29-4b7c-887f-816baf38f8c8" />
Author
Owner

@KaPyStTa commented on GitHub (Jun 5, 2026):

Hi! Go to the XRay configuration, then to the routing and configure what you need there. It is very useful if you have a cascading connection.

<!-- gh-comment-id:4628678179 --> @KaPyStTa commented on GitHub (Jun 5, 2026): Hi! Go to the XRay configuration, then to the routing and configure what you need there. It is very useful if you have a cascading connection.
Author
Owner

@LORD07Sson commented on GitHub (Jun 5, 2026):

Update your X-UI version

<!-- gh-comment-id:4631113200 --> @LORD07Sson commented on GitHub (Jun 5, 2026): Update your X-UI version
Author
Owner

@flippo2kk commented on GitHub (Jun 5, 2026):

geox-url and rule-providers are sorely missing

<!-- gh-comment-id:4631317229 --> @flippo2kk commented on GitHub (Jun 5, 2026): geox-url and rule-providers are sorely missing
Author
Owner

@heyzeyu commented on GitHub (Jul 9, 2026):

I am hitting the same limitation with native Clash/Mihomo subscriptions.

My setup:

  • One 3x-ui panel manages several scenario clients/nodes:
    • HK VPS direct exit
    • US VPS exit
    • US ISP/residential proxy exit
    • private/company network tunnel exit
  • I want to keep 3x-ui as the source of truth for clients, inbounds, quotas, traffic stats, and generated share/subscription links.

Desired Clash/Mihomo behavior:

  • One subscription URL imports the nodes generated by 3x-ui.
  • The generated YAML also includes custom proxy-groups and routing rules, for example:
    • Default traffic: selectable US ISP / US VPS / HK direct
    • Company/private domains: DIRECT when the client is on the company network, or company tunnel when outside
    • AI services: selectable or forced US exit
  • Admin can define rule-providers, rules, and proxy-groups once in the panel and bind them to a subscription/client/group/inbound.

Current workaround:

  • Use native 3x-ui subscription only for raw nodes.
  • Maintain a separate static Clash YAML, or use Sub-Store/Subconverter/client-side merge rules for proxy-groups and rules.

This works, but 3x-ui is no longer the single source of truth, and every client/device needs extra configuration outside the panel.

Suggested MVP:

  • Add a Clash/Mihomo subscription template or YAML fragment field in the panel.
  • Support variables/placeholders for generated node names.
  • Let admins inject proxy-groups, rule-providers, and rules before/after the default generated rules.
  • Optionally bind different templates/profiles to clients, client groups, inbounds, or subscription URLs.

Related issues: #5824 for routing injection and #5124 for subscription packages. This issue seems specifically about Clash/Mihomo proxy-groups/rules, so I think custom subscription templates/profiles would cover this use case well.

<!-- gh-comment-id:4920673688 --> @heyzeyu commented on GitHub (Jul 9, 2026): I am hitting the same limitation with native Clash/Mihomo subscriptions. My setup: - One 3x-ui panel manages several scenario clients/nodes: - HK VPS direct exit - US VPS exit - US ISP/residential proxy exit - private/company network tunnel exit - I want to keep 3x-ui as the source of truth for clients, inbounds, quotas, traffic stats, and generated share/subscription links. Desired Clash/Mihomo behavior: - One subscription URL imports the nodes generated by 3x-ui. - The generated YAML also includes custom proxy-groups and routing rules, for example: - Default traffic: selectable US ISP / US VPS / HK direct - Company/private domains: DIRECT when the client is on the company network, or company tunnel when outside - AI services: selectable or forced US exit - Admin can define rule-providers, rules, and proxy-groups once in the panel and bind them to a subscription/client/group/inbound. Current workaround: - Use native 3x-ui subscription only for raw nodes. - Maintain a separate static Clash YAML, or use Sub-Store/Subconverter/client-side merge rules for proxy-groups and rules. This works, but 3x-ui is no longer the single source of truth, and every client/device needs extra configuration outside the panel. Suggested MVP: - Add a Clash/Mihomo subscription template or YAML fragment field in the panel. - Support variables/placeholders for generated node names. - Let admins inject `proxy-groups`, `rule-providers`, and `rules` before/after the default generated rules. - Optionally bind different templates/profiles to clients, client groups, inbounds, or subscription URLs. Related issues: #5824 for routing injection and #5124 for subscription packages. This issue seems specifically about Clash/Mihomo proxy-groups/rules, so I think custom subscription templates/profiles would cover this use case well.
Author
Owner

@MHSanaei commented on GitHub (Jul 23, 2026):

There are two separate routing systems in the subscription settings, and "Happ only" applies to the wrong one for your goal.

The "Happ only" fields (Settings → Subscription → Happ): Enable Routing and Routing Rules only emit Routing-Enable/Routing HTTP response headers that only the Happ client reads — every other client ignores them. Not what you want for Clash.

The Clash fields (Settings → Subscription → Clash / Mihomo) are what you want: Clash Enable Routing and Clash Routing Rules. On a Clash fetch these are merged into the generated YAML. You can paste bare rule lines or a full YAML block — a rules: list containing a MATCH,... line replaces the default MATCH,PROXY catch-all; otherwise your rules are prepended before it.

Proxy groups: the base config ships one PROXY group (type select) auto-filled with all your proxies + DIRECT. Because the merge copies any other top-level key from your YAML block straight onto the config, you can override proxy groups by including a proxy-groups: key in the Clash Routing Rules block — it replaces the default group wholesale, e.g.:

proxy-groups:
  - name: PROXY
    type: select
    proxies: ["auto", "DIRECT"]
  - name: auto
    type: url-test
    proxies: []
    url: http://www.gstatic.com/generate_204
    interval: 300
rules:
  - GEOSITE,category-ir,DIRECT
  - GEOIP,ir,DIRECT
  - MATCH,PROXY

One limitation: when you override proxy-groups yourself, the panel does not auto-populate your custom groups with the generated per-node proxy names (only the built-in default PROXY group gets that), so a custom url-test referencing every node isn't fully automatic today — that auto-fill would be a valid small enhancement. For rules and basic group customization the fields above cover it, so closing as answered.

<!-- gh-comment-id:5059221282 --> @MHSanaei commented on GitHub (Jul 23, 2026): There are **two separate routing systems** in the subscription settings, and "Happ only" applies to the wrong one for your goal. **The "Happ only" fields** (Settings → Subscription → Happ): **Enable Routing** and **Routing Rules** only emit `Routing-Enable`/`Routing` HTTP response headers that only the Happ client reads — every other client ignores them. Not what you want for Clash. **The Clash fields** (Settings → Subscription → Clash / Mihomo) are what you want: **Clash Enable Routing** and **Clash Routing Rules**. On a Clash fetch these are merged into the generated YAML. You can paste bare rule lines or a full YAML block — a `rules:` list containing a `MATCH,...` line **replaces** the default `MATCH,PROXY` catch-all; otherwise your rules are prepended before it. **Proxy groups:** the base config ships one `PROXY` group (type `select`) auto-filled with all your proxies + `DIRECT`. Because the merge copies any *other* top-level key from your YAML block straight onto the config, you **can override proxy groups** by including a `proxy-groups:` key in the Clash Routing Rules block — it replaces the default group wholesale, e.g.: ```yaml proxy-groups: - name: PROXY type: select proxies: ["auto", "DIRECT"] - name: auto type: url-test proxies: [] url: http://www.gstatic.com/generate_204 interval: 300 rules: - GEOSITE,category-ir,DIRECT - GEOIP,ir,DIRECT - MATCH,PROXY ``` One limitation: when you override `proxy-groups` yourself, the panel does **not** auto-populate your custom groups with the generated per-node proxy names (only the built-in default `PROXY` group gets that), so a custom `url-test` referencing every node isn't fully automatic today — that auto-fill would be a valid small enhancement. For rules and basic group customization the fields above cover it, so closing as answered.
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#3461
No description provided.