[GH-ISSUE #6826] [Question]: Сlient receives an incorrect subscription link via the Telegram bot. #4544

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

Originally created by @0dementiy0-source on GitHub (Oct 14, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6826

What are you trying to do?

After clicking the link — the invitation — the client receives an incorrect link for subscribing via the Telegram bot. Instead of an IP address, the link contains a local hostname. In the client’s web interface, the link is correct. How can I change the hostname in the link to an IP address?

What have you already tried?

Nothing

3x-ui version

3.1.0

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

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 @0dementiy0-source on GitHub (Oct 14, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6826 ### What are you trying to do? After clicking the link — the invitation — the client receives an incorrect link for subscribing via the Telegram bot. Instead of an IP address, the link contains a local hostname. In the client’s web interface, the link is correct. How can I change the hostname in the link to an IP address? ### What have you already tried? Nothing ### 3x-ui version 3.1.0 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### 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:40:24 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 14, 2026):

The bot falls back to the server's OS hostname because it has no browser request to take a host from. You can fix it with one setting: put your public IP into Panel Settings → Subscription → Reverse Proxy URI (subURI). #5851 had the same cause, so I'm closing this as a duplicate of it.

Why the web UI and the bot differ

  • Web UI. When subDomain is empty, the panel builds the link from the host in your browser's address bar. BuildSubURIBase (internal/web/service/setting.go:1913-1915):
    if subDomain == "" {
        subDomain = extractHostname(host)
    }
    
  • Telegram bot. There is no HTTP request, so buildSubscriptionURLs (internal/web/service/tgbot/tgbot_client.go:167-176) falls back to the panel domain, then the OS hostname, then localhost:
    // try panel domain, otherwise OS hostname
    if d, err := t.settingService.GetWebDomain(); err == nil && d != "" {
        subDomain = d
    } else if hostname != "" {
        subDomain = hostname
    

How to fix it

  1. In the panel, open a client's info and copy the subscription link the web UI shows. It already has the right IP, port and path. The path is randomised at install (setting.go:400), so copy it instead of typing /sub/.
  2. Go to Panel Settings → Subscription and paste everything up to and including the path into Reverse Proxy URI, without the client's ID at the end. For example:
    http://203.0.113.10:2096/abcdefgh12345678/
    
  3. If the JSON subscription is enabled, do the same for the JSON subscription's URI field (subJsonURI).
  4. Save and restart the panel.

The bot uses these fields exactly as written whenever they are set (tgbot_client.go:203-207 and 212-216). The web UI reads subURI too, so both will show the same link.

I'd avoid putting the IP into the subscription Listen Domain (subDomain) instead. That field also turns on host checking for the subscription server (internal/sub/sub.go:63-64, DomainValidatorMiddleware(subDomain)), so requests that arrive under any other name would be rejected.

Verdict: Duplicate
Severity: N/A
Confidence: High
Root cause: buildSubscriptionURLs (internal/web/service/tgbot/tgbot_client.go:167-176) falls back to webDomain, then os.Hostname(), when subURI/subDomain are empty; the web UI uses the request Host instead (setting.go:1913-1915). Introduced with the bot's subscription links in ed96fa09 ("tgbot: subscription,qrcode, link").
Same class: None found beyond the three bot callers of buildSubscriptionURLs (tgbot_client.go:229, 265, 300), which all share this fallback
Already fixed: Still present on the default branch (v3.10.2); the hostname fallback is unchanged
Duplicate of: #5851, same hostname fallback in buildSubscriptionURLs; also Related: #6021
Evidence: tgbot_client.go:167-176 and 203-207; setting.go:1907-1924 (BuildSubURIBase); internal/sub/sub.go:63-64
Not determined: None

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

<!-- gh-comment-id:6174096387 --> @github-actions[bot] commented on GitHub (Oct 14, 2026): The bot falls back to the server's OS hostname because it has no browser request to take a host from. You can fix it with one setting: put your public IP into **Panel Settings → Subscription → `Reverse Proxy URI`** (`subURI`). #5851 had the same cause, so I'm closing this as a duplicate of it. **Why the web UI and the bot differ** - **Web UI.** When `subDomain` is empty, the panel builds the link from the host in your browser's address bar. `BuildSubURIBase` (`internal/web/service/setting.go:1913-1915`): ```go if subDomain == "" { subDomain = extractHostname(host) } ``` - **Telegram bot.** There is no HTTP request, so `buildSubscriptionURLs` (`internal/web/service/tgbot/tgbot_client.go:167-176`) falls back to the panel domain, then the OS hostname, then `localhost`: ```go // try panel domain, otherwise OS hostname if d, err := t.settingService.GetWebDomain(); err == nil && d != "" { subDomain = d } else if hostname != "" { subDomain = hostname ``` **How to fix it** 1. In the panel, open a client's info and copy the subscription link the web UI shows. It already has the right IP, port and path. The path is randomised at install (`setting.go:400`), so copy it instead of typing `/sub/`. 2. Go to **Panel Settings → Subscription** and paste everything up to and including the path into **`Reverse Proxy URI`**, without the client's ID at the end. For example: ``` http://203.0.113.10:2096/abcdefgh12345678/ ``` 3. If the JSON subscription is enabled, do the same for the JSON subscription's URI field (`subJsonURI`). 4. Save and restart the panel. The bot uses these fields exactly as written whenever they are set (`tgbot_client.go:203-207` and `212-216`). The web UI reads `subURI` too, so both will show the same link. I'd avoid putting the IP into the subscription **`Listen Domain`** (`subDomain`) instead. That field also turns on host checking for the subscription server (`internal/sub/sub.go:63-64`, `DomainValidatorMiddleware(subDomain)`), so requests that arrive under any other name would be rejected. Verdict: Duplicate Severity: N/A Confidence: High Root cause: `buildSubscriptionURLs` (`internal/web/service/tgbot/tgbot_client.go:167-176`) falls back to `webDomain`, then `os.Hostname()`, when `subURI`/`subDomain` are empty; the web UI uses the request Host instead (`setting.go:1913-1915`). Introduced with the bot's subscription links in `ed96fa09` ("tgbot: subscription,qrcode, link"). Same class: None found beyond the three bot callers of `buildSubscriptionURLs` (`tgbot_client.go:229`, `265`, `300`), which all share this fallback Already fixed: Still present on the default branch (v3.10.2); the hostname fallback is unchanged Duplicate of: #5851, same hostname fallback in `buildSubscriptionURLs`; also Related: #6021 Evidence: `tgbot_client.go:167-176` and `203-207`; `setting.go:1907-1924` (`BuildSubURIBase`); `internal/sub/sub.go:63-64` Not determined: None *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4544
No description provided.