[GH-ISSUE #6251] [Question]: Custom domain override for client links #4240

Closed
opened 2026-10-31 20:38:13 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @BismuthumOS on GitHub (Aug 18, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6251

What are you trying to do?

Hello!
My 3x-ui panel is running on docker and bound to 127.0.0.1 for security. I open the web panel on my PC via an SSH tunnel at http://localhost:2053. Because of this, all generated client links (vless, hysteria, etc.) contain "localhost" instead of my actual domain or server IP The panel takes the address directly from my browser URL or something?
And I have to manually edit my client URLs to my actual Domain every time I generate them. Is it possible to add a simple setting in the panel to force a specific default domain or IP for all generated client links? Or maybe I missed some env variable/web ui setting?
Thank you!

What have you already tried?

No response

3x-ui version

3.6.0

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Debian 13

Screenshots or config snippets

No response

Before submitting

  • I read the Wiki and searched existing issues.
  • This is a usage question, not a bug report.
  • This question is written in English.
Originally created by @BismuthumOS on GitHub (Aug 18, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6251 ### What are you trying to do? Hello! My 3x-ui panel is running on docker and bound to 127.0.0.1 for security. I open the web panel on my PC via an SSH tunnel at http://localhost:2053. Because of this, all generated client links (vless, hysteria, etc.) contain "localhost" instead of my actual domain or server IP The panel takes the address directly from my browser URL or something? And I have to manually edit my client URLs to my actual Domain every time I generate them. Is it possible to add a simple setting in the panel to force a specific default domain or IP for all generated client links? Or maybe I missed some env variable/web ui setting? Thank you! ### What have you already tried? _No response_ ### 3x-ui version 3.6.0 ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Debian 13 ### Screenshots or config snippets _No response_ ### Before submitting - [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue). - [x] This is a usage question, not a bug report. - [x] This question is written in English.
bsakaguchi 2026-10-31 20:38:14 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 18, 2026):

The setting already exists in 3.6.0 — the panel only falls back to your browser's hostname when no public host is configured, so nothing needs to be added.

How the link host is chosen (paths/line numbers from current main):

  • Share links and QR codes are built in the browser. frontend/src/pages/inbounds/InboundsPage.tsx:288 passes preferPublicHost(window.location.hostname, subSettings.publicHost) as the last-resort host into resolveShareHost (frontend/src/lib/xray/inbound-link.ts:1010), where publicHost is subDomain || webDomain (frontend/src/pages/inbounds/useInbounds.ts:179).
  • The subscription server does the same server-side in resolveInboundAddress and configuredPublicHost (internal/sub/service.go:1162 and :210).
  • Priority in both: per-inbound node address / listen address / custom share address, then the configured public host (subDomain, then webDomain), then the host your browser used. localhost, 127.x and ::1 are rejected as link hosts (isShareableHost, inbound-link.ts:974), so with nothing configured the browser host is the only candidate left. That is exactly what you are seeing.

Two ways to fix it:

  1. Global, applies to every link, QR code and the subscription URL — Settings → Subscription → Listen Domain (subDomain). Set it to your FQDN or public IP.
    Note that subDomain also installs a Host-header check on the subscription server (port 2096): internal/sub/sub.go:63 wires DomainValidatorMiddleware, so requests to the sub server whose Host is not exactly that value get 403. It does not affect panel access.
  2. Per inbound, no side effects — edit the inbound and set Share address strategy to Custom, then fill Custom share address with the host or IP (no scheme, no port). Backend fields are shareAddrStrategy / shareAddr in internal/database/model/model.go.

One thing to avoid: do not use Settings → General → Listen Domain (webDomain) for this. It enables DomainValidatorMiddleware on the panel itself (internal/web/web.go:182), which returns 403 for any request whose Host is not that domain — you would lose access to http://localhost:2053 through your SSH tunnel. It is only consulted as the public-host fallback when subDomain is empty.

Closing this as a duplicate of #6013, which is the same scenario (panel reached over an SSH tunnel on a loopback host) with the same resolution. Please continue the discussion there if the above does not cover your case.

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

<!-- gh-comment-id:5328392914 --> @github-actions[bot] commented on GitHub (Aug 18, 2026): The setting already exists in 3.6.0 — the panel only falls back to your browser's hostname when no public host is configured, so nothing needs to be added. How the link host is chosen (paths/line numbers from current `main`): - Share links and QR codes are built in the browser. `frontend/src/pages/inbounds/InboundsPage.tsx:288` passes `preferPublicHost(window.location.hostname, subSettings.publicHost)` as the last-resort host into `resolveShareHost` (`frontend/src/lib/xray/inbound-link.ts:1010`), where `publicHost` is `subDomain || webDomain` (`frontend/src/pages/inbounds/useInbounds.ts:179`). - The subscription server does the same server-side in `resolveInboundAddress` and `configuredPublicHost` (`internal/sub/service.go:1162` and `:210`). - Priority in both: per-inbound node address / listen address / custom share address, then the configured public host (`subDomain`, then `webDomain`), then the host your browser used. `localhost`, `127.x` and `::1` are rejected as link hosts (`isShareableHost`, `inbound-link.ts:974`), so with nothing configured the browser host is the only candidate left. That is exactly what you are seeing. Two ways to fix it: 1. Global, applies to every link, QR code and the subscription URL — **Settings → Subscription → Listen Domain** (`subDomain`). Set it to your FQDN or public IP. Note that `subDomain` also installs a Host-header check on the subscription server (port 2096): `internal/sub/sub.go:63` wires `DomainValidatorMiddleware`, so requests to the sub server whose Host is not exactly that value get `403`. It does not affect panel access. 2. Per inbound, no side effects — edit the inbound and set **Share address strategy** to **Custom**, then fill **Custom share address** with the host or IP (no scheme, no port). Backend fields are `shareAddrStrategy` / `shareAddr` in `internal/database/model/model.go`. One thing to avoid: do not use **Settings → General → Listen Domain** (`webDomain`) for this. It enables `DomainValidatorMiddleware` on the panel itself (`internal/web/web.go:182`), which returns `403` for any request whose Host is not that domain — you would lose access to `http://localhost:2053` through your SSH tunnel. It is only consulted as the public-host fallback when `subDomain` is empty. Closing this as a duplicate of #6013, which is the same scenario (panel reached over an SSH tunnel on a loopback host) with the same resolution. Please continue the discussion there if the above does not cover your case. *This reply was generated automatically; a maintainer may follow up.*
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#4240
No description provided.