[GH-ISSUE #4798] [Bug]: Wrong ip in vless config #3334

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

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

Describe the bug

Continue #4750

I can confirm this issue is still present.

My setup:

  • Panel is running in Docker using network_mode: "host"
  • Inbound settings: The Address field is explicitly set to my server's external VPS IP.

The problem:
When generating client links/QR codes, the panel dynamically injects the local IP address of the device I am currently using to access the web UI (e.g., my phone's or laptop's IP) instead of using the VPS server's IP or the address configured in the inbound.

None of the workarounds (setting the Address in the inbound or changing panel settings) seem to fix this behavior.

How to reproduce the problem

  1. create client
  2. generate qr or copy link
  3. open qr/link

Expected behavior

  1. create client
  2. generate qr or copy link
  3. open qr/link - server ip is correct

Actual behavior

ip is wrong

Relevant logs


Screenshots

No response

3x-ui version

3.2.6

Xray-core version

26.6.1

How did you install 3x-ui?

Docker / Docker Compose

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

  • 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 @gotyefrid on GitHub (Jun 2, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4798 ### Describe the bug Continue #4750 I can confirm this issue is still present. My setup: - Panel is running in Docker using `network_mode: "host"` - Inbound settings: The `Address` field is explicitly set to my server's external VPS IP. The problem: When generating client links/QR codes, the panel dynamically injects the local IP address of the device I am currently using to access the web UI (e.g., my phone's or laptop's IP) instead of using the VPS server's IP or the address configured in the inbound. None of the workarounds (setting the Address in the inbound or changing panel settings) seem to fix this behavior. ### How to reproduce the problem 1. create client 2. generate qr or copy link 3. open qr/link ### Expected behavior 1. create client 2. generate qr or copy link 3. open qr/link - server ip is correct ### Actual behavior ip is wrong ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.2.6 ### Xray-core version 26.6.1 ### How did you install 3x-ui? Docker / Docker Compose ### 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 - [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:31:43 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Thanks for the detailed report and for confirming this is still present in v3.2.6.

Root cause

When generating client links/QR codes, the panel determines the server address from the incoming HTTP request via resolveHost() (web/controller/inbound.go). The priority order is:

  1. X-Forwarded-Host header — if the request came from a trusted proxy
  2. X-Real-IP header — fallback when X-Forwarded-Host is absent, but the request is still from a trusted proxy
  3. c.Request.Host — the Host header the browser sent (the URL you typed)

Important: The inbound's "Address/Listen" field is intentionally not used for link generation — it controls the server-side bind address, not the advertised client-reachable host. Per-inbound address overrides must go through External Proxy instead.

Behind Nginx (the common case from #4750)

A typical Nginx config sets:

proxy_set_header X-Real-IP $remote_addr;  # ← this is the *browser user's* IP

Because the panel receives the request from 127.0.0.1 (Nginx), 127.0.0.1 is in the default trusted-proxy list (127.0.0.1/32,::1/128). The panel then reads X-Real-IP, which Nginx has set to the client device's IP (your phone/laptop) — and that IP ends up in the generated link. This is the confirmed bug.

Fix for Nginx setups: Add X-Forwarded-Host to your Nginx config so the panel uses the correct server hostname/IP instead of the client's IP:

proxy_set_header X-Forwarded-Host  $http_host;    # ← add this line
proxy_set_header X-Real-IP         $remote_addr;
proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

X-Forwarded-Host takes priority over X-Real-IP in resolveHost(), so once it is present and contains your panel's domain/IP, the correct value will be used for link generation.

Direct Docker / no proxy

With network_mode: "host" and no Nginx, the fallback path (c.Request.Host) is used — which is whatever hostname/IP your browser has in its URL bar. If you access the panel at http://1.2.3.4:2053, the links should contain 1.2.3.4.

Could you confirm:

  • What URL do you use to open the panel (e.g. http://<VPS-IP>:<port> or a domain)?
  • What exact IP appears in the generated links — is it your device's private IP (e.g. 192.168.x.x) or something else?

This will help confirm whether the no-proxy path also has a regression or if there is a configuration detail causing it.

Panel-settings override (partial workaround)

Panel Settings → Subscription → Listen Domain (subDomain) is used as the host override, but currently only when the resolved request host is non-routable (loopback/unspecified). It does not override a private IP that leaks through X-Real-IP, so this setting alone is not a reliable fix for the Nginx case — the X-Forwarded-Host header change above is necessary.

<!-- gh-comment-id:4599783502 --> @github-actions[bot] commented on GitHub (Jun 2, 2026): Thanks for the detailed report and for confirming this is still present in v3.2.6. ## Root cause When generating client links/QR codes, the panel determines the server address from the incoming HTTP request via `resolveHost()` (`web/controller/inbound.go`). The priority order is: 1. **`X-Forwarded-Host` header** — if the request came from a trusted proxy 2. **`X-Real-IP` header** — fallback when `X-Forwarded-Host` is absent, but the request is still from a trusted proxy 3. **`c.Request.Host`** — the `Host` header the browser sent (the URL you typed) > **Important:** The inbound's "Address/Listen" field is intentionally **not used** for link generation — it controls the server-side bind address, not the advertised client-reachable host. Per-inbound address overrides must go through **External Proxy** instead. ## Behind Nginx (the common case from #4750) A typical Nginx config sets: ```nginx proxy_set_header X-Real-IP $remote_addr; # ← this is the *browser user's* IP ``` Because the panel receives the request from `127.0.0.1` (Nginx), `127.0.0.1` is in the default trusted-proxy list (`127.0.0.1/32,::1/128`). The panel then reads `X-Real-IP`, which Nginx has set to the **client device's IP** (your phone/laptop) — and that IP ends up in the generated link. This is the confirmed bug. **Fix for Nginx setups:** Add `X-Forwarded-Host` to your Nginx config so the panel uses the correct server hostname/IP instead of the client's IP: ```nginx proxy_set_header X-Forwarded-Host $http_host; # ← add this line proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; ``` `X-Forwarded-Host` takes priority over `X-Real-IP` in `resolveHost()`, so once it is present and contains your panel's domain/IP, the correct value will be used for link generation. ## Direct Docker / no proxy With `network_mode: "host"` and no Nginx, the fallback path (`c.Request.Host`) is used — which is whatever hostname/IP your browser has in its URL bar. If you access the panel at `http://1.2.3.4:2053`, the links should contain `1.2.3.4`. Could you confirm: - What URL do you use to open the panel (e.g. `http://<VPS-IP>:<port>` or a domain)? - What exact IP appears in the generated links — is it your device's private IP (e.g. `192.168.x.x`) or something else? This will help confirm whether the no-proxy path also has a regression or if there is a configuration detail causing it. ## Panel-settings override (partial workaround) **Panel Settings → Subscription → Listen Domain** (`subDomain`) is used as the host override, but currently only when the resolved request host is non-routable (loopback/unspecified). It does **not** override a private IP that leaks through `X-Real-IP`, so this setting alone is not a reliable fix for the Nginx case — the `X-Forwarded-Host` header change above is necessary.
Author
Owner

@Ketty0725 commented on GitHub (Jun 2, 2026):

I also encountered the same issue. In versions 3.2.0 and earlier, after changing the Inbound settings address to the VPS's IP, the exported subscription displayed the correct IP. However, versions 3.2.5 and 3.2.6 broke this balance, and no matter how it was set, it couldn't be changed to the specified IP.

<!-- gh-comment-id:4599817755 --> @Ketty0725 commented on GitHub (Jun 2, 2026): I also encountered the same issue. In versions 3.2.0 and earlier, after changing the Inbound settings address to the VPS's IP, the exported subscription displayed the correct IP. However, versions 3.2.5 and 3.2.6 broke this balance, and no matter how it was set, it couldn't be changed to the specified IP.
Author
Owner

@DervilRus commented on GitHub (Jun 2, 2026):

I also encountered this issue in 3.2.6. I used to use a separate IP for each inbound, but now my subscription shows all inbounds with the domain I access, not the IP specified in each inbound.

<!-- gh-comment-id:4603575505 --> @DervilRus commented on GitHub (Jun 2, 2026): I also encountered this issue in 3.2.6. I used to use a separate IP for each inbound, but now my subscription shows all inbounds with the domain I access, not the IP specified in each inbound.
Author
Owner

@djbelous-coder commented on GitHub (Jun 2, 2026):

I have the same bug. But I am using SSH port forwarding to access to panel, so my address is http://127.0.0.1:22222/panel/ and of course in logs I see 127.0.0.1 and I have wrong client configs with "localhost" instead IP. I think Its happen begging v3.2.5

<!-- gh-comment-id:4606210394 --> @djbelous-coder commented on GitHub (Jun 2, 2026): I have the same bug. But I am using SSH port forwarding to access to panel, so my address is http://127.0.0.1:22222/panel/ and of course in logs I see 127.0.0.1 and I have wrong client configs with "localhost" instead IP. I think Its happen begging v3.2.5
Author
Owner

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

Fixed — this was a regression introduced in 3.2.5/3.2.6.

Root cause: resolveInboundAddress stopped using the inbound's bind Listen/Address when generating subscription and share links, so it always advertised the host you reached the panel on (the request host / X-Real-IP) instead of the per-inbound IP. The panel QR path still honored Listen, which is why the panel and the exported subscription disagreed.

Fix: The inbound's Listen is advertised again in subscription/share links when it is a routable address (a real IP or hostname). So setting an inbound's Address to your VPS IP — or a different IP per inbound — works as it did in ≤ 3.2.0.

Loopback (127.0.0.1/::1), wildcard (0.0.0.0/::), and unix-socket binds still fall back to the subscriber host, so the earlier loopback-leak fix stays intact (a 0.0.0.0 inbound keeps using the host you connect on). External Proxy and node addresses keep their higher precedence.

Verified end-to-end in Docker: an inbound with Listen 203.0.113.7 now produces vless://…@203.0.113.7:… even when the panel is reached over 127.0.0.1, while a 0.0.0.0 inbound still falls back to the request host.

Will ship in the next release.

<!-- gh-comment-id:4606553371 --> @MHSanaei commented on GitHub (Jun 2, 2026): Fixed — this was a regression introduced in 3.2.5/3.2.6. **Root cause:** `resolveInboundAddress` stopped using the inbound's bind **Listen/Address** when generating subscription and share links, so it always advertised the host you reached the panel on (the request host / `X-Real-IP`) instead of the per-inbound IP. The panel QR path still honored Listen, which is why the panel and the exported subscription disagreed. **Fix:** The inbound's Listen is advertised again in subscription/share links **when it is a routable address** (a real IP or hostname). So setting an inbound's Address to your VPS IP — or a different IP per inbound — works as it did in ≤ 3.2.0. Loopback (`127.0.0.1`/`::1`), wildcard (`0.0.0.0`/`::`), and unix-socket binds still fall back to the subscriber host, so the earlier loopback-leak fix stays intact (a `0.0.0.0` inbound keeps using the host you connect on). External Proxy and node addresses keep their higher precedence. Verified end-to-end in Docker: an inbound with Listen `203.0.113.7` now produces `vless://…@203.0.113.7:…` even when the panel is reached over `127.0.0.1`, while a `0.0.0.0` inbound still falls back to the request host. Will ship in the next release.
Author
Owner

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

please test
https://github.com/MHSanaei/3x-ui/actions/runs/26844794568

<!-- gh-comment-id:4606561312 --> @MHSanaei commented on GitHub (Jun 2, 2026): please test https://github.com/MHSanaei/3x-ui/actions/runs/26844794568
Author
Owner

@DervilRus commented on GitHub (Jun 9, 2026):

This has been fixed for subscriptions from single nodes. If you take a subscription to which all other nodes are connected, then instead of an IP, the domain through which the node is connected is again used.

<!-- gh-comment-id:4658457876 --> @DervilRus commented on GitHub (Jun 9, 2026): This has been fixed for subscriptions from single nodes. If you take a subscription to which all other nodes are connected, then instead of an IP, the domain through which the node is connected is again used.
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#3334
No description provided.