[GH-ISSUE #5836] [Bug]: Subscription replaces server address with client local IP #4056

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

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

  1. Create an inbound on the server with address 203.0.113.10 and port 8443.
  2. Generate a subscription link and import it into Happ (Windows).
  3. Open the imported server profile.
  4. Observe that the address field contains the client/local IP instead of 203.0.113.10.
  5. Try to connect — no working internet through the intended server.

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

  • 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 @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 1. Create an inbound on the server with address 203.0.113.10 and port 8443. 2. Generate a subscription link and import it into Happ (Windows). 3. Open the imported server profile. 4. Observe that the address field contains the client/local IP instead of 203.0.113.10. 5. Try to connect — no working internet through the intended server. ### 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 ```shell ``` ### 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 - [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:36:49 +07:00
Author
Owner

@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's Listen IP (only if it's a real, non-wildcard address) -> the configured "Sub Domain"/"Web Domain" setting -> finally s.address, which is derived from the HTTP request used to fetch the subscription. For a single-server Docker install with the inbound listening on 0.0.0.0/blank and no per-inbound custom share address, the chain falls through to that last option.

s.address comes from the /sub/:subid handler calling ResolveRequest (internal/sub/service.go:2453), which builds the host by checking, in this order: the X-Forwarded-Host header, then the X-Real-IP header, then the raw Host header 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: resolveHost in internal/web/controller/inbound.go:421 only trusts those same headers when the immediate peer matches the "Trusted proxy CIDRs" setting (internal/web/controller/util.go:43, default 127.0.0.1/32,::1/128). If your reverse proxy/CDN sets X-Real-IP to 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 exported vless://...@<address>:<port> (and other protocol) links instead of 203.0.113.10.

Workaround — any of these stops the fallback from ever reaching the request-derived host:

  • Settings → Subscription → General tab → Listen Domain (subDomain): set to 203.0.113.10 (or a hostname resolving to it).
  • Settings → General tab → Listen Domain (webDomain): same value, as a second fallback.
  • On the specific inbound: Edit → Basics tab → Share address strategy = Custom, then Custom share address = 203.0.113.10. This takes priority over everything else in resolveInboundAddress, independent of what the reverse proxy forwards.

To confirm the exact trigger, please provide:

  1. Whether "Sub Domain" (Settings → Subscription → General) or "Web Domain" (Settings → General) is currently set.
  2. Your reverse proxy/CDN configuration for the subscription path — specifically whether it sets X-Forwarded-Host or X-Real-IP, or rewrites the Host header, on requests it forwards to 3x-ui.
  3. The exact value that lands in the generated link (redact anything sensitive) — is it a private/LAN address, or the workstation's actual public IP?

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

<!-- gh-comment-id:4896674690 --> @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's `Listen` IP (only if it's a real, non-wildcard address) -> the configured "Sub Domain"/"Web Domain" setting -> finally `s.address`, which is derived from the HTTP request used to fetch the subscription. For a single-server Docker install with the inbound listening on `0.0.0.0`/blank and no per-inbound custom share address, the chain falls through to that last option. `s.address` comes from the `/sub/:subid` handler calling `ResolveRequest` (`internal/sub/service.go:2453`), which builds the host by checking, in this order: the `X-Forwarded-Host` header, then the `X-Real-IP` header, then the raw `Host` header 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: `resolveHost` in `internal/web/controller/inbound.go:421` only trusts those same headers when the immediate peer matches the "Trusted proxy CIDRs" setting (`internal/web/controller/util.go:43`, default `127.0.0.1/32,::1/128`). If your reverse proxy/CDN sets `X-Real-IP` to 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 exported `vless://...@<address>:<port>` (and other protocol) links instead of `203.0.113.10`. **Workaround** — any of these stops the fallback from ever reaching the request-derived host: - Settings → **Subscription** → **General** tab → **Listen Domain** (`subDomain`): set to `203.0.113.10` (or a hostname resolving to it). - Settings → **General** tab → **Listen Domain** (`webDomain`): same value, as a second fallback. - On the specific inbound: Edit → **Basics** tab → **Share address strategy** = `Custom`, then **Custom share address** = `203.0.113.10`. This takes priority over everything else in `resolveInboundAddress`, independent of what the reverse proxy forwards. **To confirm the exact trigger, please provide:** 1. Whether "Sub Domain" (Settings → Subscription → General) or "Web Domain" (Settings → General) is currently set. 2. Your reverse proxy/CDN configuration for the subscription path — specifically whether it sets `X-Forwarded-Host` or `X-Real-IP`, or rewrites the `Host` header, on requests it forwards to 3x-ui. 3. The exact value that lands in the generated link (redact anything sensitive) — is it a private/LAN address, or the workstation's actual public IP? *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@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.

<!-- gh-comment-id:4896772124 --> @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.
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#4056
No description provided.