mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5836] [Bug]: Subscription replaces server address with client local IP #4056
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#4056
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 @moshkinura on GitHub (Jul 6, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5836
Describe the bug
When importing a subscription (or connection profile), the client substitutes my local/client IP into the server address field instead of keeping the configured server IP.
Because of this, the connection profile points to the wrong host, and traffic does not go through the intended VPN node.
How to reproduce the problem
Expected behavior
The subscription should preserve the server address from the panel/config (e.g. 203.0.113.10) and the correct inbound port (e.g. 8443).
The client should connect to the remote server, not to the local machine.
P.S The IP and port have been changed for security reasons
Actual behavior
After importing the subscription, the server address is replaced with my computer’s local IP.
Connection either fails or has no internet, because the profile no longer targets the remote server.
Relevant logs
Screenshots
No response
3x-ui version
3.4.2
Xray-core version
26.6.27
How did you install 3x-ui?
Docker / Docker Compose
Operating system
Ubuntu24.04
Which parts of the panel are affected?
Subscription (share links / Clash / JSON)
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — other
Before submitting
@github-actions[bot] commented on GitHub (Jul 6, 2026):
This is subscription-side address resolution, not a Happ/client bug — confirmed in
internal/sub/service.go.How the embedded address is chosen
For each protocol link,
resolveInboundAddress(internal/sub/service.go:1125) tries, in order: the client's Node address (multi-node only) -> the inbound'sListenIP (only if it's a real, non-wildcard address) -> the configured "Sub Domain"/"Web Domain" setting -> finallys.address, which is derived from the HTTP request used to fetch the subscription. For a single-server Docker install with the inbound listening on0.0.0.0/blank and no per-inbound custom share address, the chain falls through to that last option.s.addresscomes from the/sub/:subidhandler callingResolveRequest(internal/sub/service.go:2453), which builds the host by checking, in this order: theX-Forwarded-Hostheader, then theX-Real-IPheader, then the rawHostheader of the connection — and it does so unconditionally, without verifying the request actually came through a trusted proxy. That's inconsistent with the rest of the panel:resolveHostininternal/web/controller/inbound.go:421only trusts those same headers when the immediate peer matches the "Trusted proxy CIDRs" setting (internal/web/controller/util.go:43, default127.0.0.1/32,::1/128). If your reverse proxy/CDN setsX-Real-IPto the connecting client's address (normal behavior, used for logging) and neither Sub Domain nor Web Domain is set in the panel, that client-side address is what gets written into the exportedvless://...@<address>:<port>(and other protocol) links instead of203.0.113.10.Workaround — any of these stops the fallback from ever reaching the request-derived host:
subDomain): set to203.0.113.10(or a hostname resolving to it).webDomain): same value, as a second fallback.Custom, then Custom share address =203.0.113.10. This takes priority over everything else inresolveInboundAddress, independent of what the reverse proxy forwards.To confirm the exact trigger, please provide:
X-Forwarded-HostorX-Real-IP, or rewrites theHostheader, on requests it forwards to 3x-ui.This reply was generated automatically; a maintainer may follow up.
@moshkinura commented on GitHub (Jul 6, 2026):
Workaround confirmed: setting Sub Domain and Web Domain to the server IP (203.0.113.10) fixed the subscription — generated links now contain the correct remote address. No per-inbound Custom share address was needed.
Thanks for the explanation. Closing as resolved on my side.