mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4915] [Bug]: 使用订阅转换时会把本地面板识别成本机网络 #3436
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3436
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yifeng623 on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4915
Describe the bug
当有多个节点 使用订阅转换https://acl4ssr-sub.github.io/ 本地节点的会被识别成订阅转换的地址 可能是127.0.0.1这个造成的
How to reproduce the problem
使用订阅转换https://acl4ssr-sub.github.io/ 转换clash的 本地节点会被识别成api.wcc.best
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.2.7
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
ubuntu
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
@github-actions[bot] commented on GitHub (Jun 4, 2026):
感谢反馈!已查看相关源码,确认这是一个真实的代码级 Bug,以下是分析与临时解决方案。
根本原因
acl4ssr(通过api.wcc.best后端)在请求你面板订阅地址时,会在 HTTP 请求头里注入X-Forwarded-Host: api.wcc.best,表明自己是一个代理。3x-ui 的
ResolveRequest(sub/subService.go第 1979 行)优先读取X-Forwarded-Host,将其作为请求来源主机:随后
PrepareForRequest(第 56 行)的逻辑如下:由于
api.wcc.best是可路由的域名,代码不会读取面板"设置 → 订阅 → 订阅域名(subDomain)"里配置的值,而是直接用api.wcc.best作为地址。最终在
resolveInboundAddress(第 727 行),对于监听地址为127.0.0.1或0.0.0.0的入站(这两个都不是可对外路由的地址),会回退到s.address:因此订阅链接里出现了
api.wcc.best作为服务器地址。当前版本(3.2.7)的临时解决方案
推荐方案:使用面板内置的 Clash 订阅,不走第三方转换器
subClashEnable,默认关闭)http://服务器IP:端口/clash/<subid>acl4ssr或其他第三方转换器这样 Clash 客户端直接请求你的面板,
Host头就是你服务器的真实 IP/域名,不会出现地址被替换的问题。代码层面的修复方向
真正的修复是:若面板中已配置
subDomain(或webDomain),PrepareForRequest应始终优先使用该配置值,而不仅仅是在请求来源不可路由时才使用。目前代码只在请求主机为回环/未指定地址时才读取已配置的域名,导致第三方代理注入的域名可以覆盖本应使用的服务器地址。@MHSanaei commented on GitHub (Jun 4, 2026):
english please