mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5867] [Bug]: [Feature Request]: Allow manual IP override for Let's Encrypt IP SSL due to Asymmetric Routing #4074
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#4074
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 @iran100 on GitHub (Jul 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5867
Describe the bug
When trying to obtain a 6-day Let's Encrypt SSL certificate for the server IP (Option 20 -> Option 6), the script auto-detects an incorrect public IP. In certain Iranian ISPs (like MobinNet), asymmetric routing causes external IP API checkers to return an international transit/gateway node IP instead of the server's actual incoming public IP. This makes it impossible to successfully issue or use the SSL certificate.
How to reproduce the problem
x-uimanagement script via terminal.Expected behavior
The script should either ask for confirmation before proceeding with the detected IP, or provide a fallback prompt allowing the user to manually enter/override their actual incoming public IP address.
Actual behavior
[INF] Server IP detected: 31.171.101.xxx (Returns transit IP instead of actual server IP)
Relevant logs
Screenshots
No response
3x-ui version
3.4.2
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Debian 12
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
@github-actions[bot] commented on GitHub (Jul 9, 2026):
Confirmed in source: the IP auto-detection in
ssl_cert_issue_for_ip()(x-ui.sh, menu option 20 → 6) has no confirmation or override step when a provider returns a plausible-but-wrong address.Root cause (
x-ui.sh:1524-1563): the function queries a fixed list of external IP-echo services in order and uses the first one that returns HTTP 200 with an IPv4-looking body:The manual
read -rp "Please enter your server's public IPv4 address:"prompt (lines 1551-1561) only triggers if every provider fails outright andserver_ipstays empty. If any provider returns a syntactically valid IPv4 address — even the wrong one, as you describe happening with asymmetric routing on your ISP routing outbound probe traffic through a different transit/gateway node than the one inbound HTTP-01 validation would use — the script logsServer IP detected: ...(line 1563, matching your log exactly) and proceeds straight to certificate issuance with no chance to confirm or override.This is the same class of gap reported in #3910 (there triggered by
ALL_PROXYrather than asymmetric routing). That issue was closed after the reporter described a local patch adding a confirm/override prompt, but that change was never merged: I checked both the currentmainbranch and thev3.4.2tag you're running, andssl_cert_issue_for_ip()is identical in both — no such prompt exists in either.Workaround until this is addressed: bypass the script's auto-detection by issuing the certificate yourself with your real incoming IP, then wire it into the panel:
This mirrors what option 6 runs internally (same
--server letsencrypt --certificate-profile shortlived --days 6flags), just with an IP you supply instead of the auto-detected one.x-ui cert -webCert/-webCertKeyis the documented CLI flag for pointing the panel at an existing certificate (main.go,setting/certsubcommands).@MHSanaei — requesting your input: add a confirm/override prompt right after
LOGI "Server IP detected: ${server_ip}"(x-ui.sh:1563) inssl_cert_issue_for_ip(), similar in spirit to the manual-entry prompt already used a few lines above for the total-detection-failure case.This reply was generated automatically; a maintainer may follow up.
@MHSanaei commented on GitHub (Jul 9, 2026):
@claude make a pr and add a confirm public ipv4
@github-actions[bot] commented on GitHub (Jul 9, 2026):
Claude finished @MHSanaei's task in 5m 46s —— View job •
claude/issue-5867-20260709-0833• Create PR ➔Tasks
x-ui.shssl_cert_issue_for_ip()to confirm exact linesSummary
Added a confirmation step to
ssl_cert_issue_for_ip()inx-ui.sh(menu option 20 → 6), right after the existingLOGI "Server IP detected: ${server_ip}"line the automated triage comment pointed to.Behavior change:
URL_listsproviders now also sets a newip_auto_detectedflag when it succeeds.Is <ip> the correct incoming public IPv4 address for this server? [Default y], using the sameconfirm()helper already used elsewhere in the script (e.g. the "Do you want to proceed?" prompt a few lines above).ykeeps existing behavior (proceeds with the detected IP) — no change for the common case where detection is correct.nclearsserver_ipand reuses the existing manual-entry validation loop (same IPv4 regex check used in the all-providers-failed path) so the user can type in their real incoming public IP — directly addressing the asymmetric-routing case from MobinNet where probe traffic exits through a different transit/gateway node than inbound HTTP-01 validation would use.This is a minimal, self-contained change to the one function; no other files needed updates (no Go/frontend/i18n/OpenAPI surface is touched since this is a pure bash install-script change).
Note on verification: this sandbox's tool permissions require approval for any direct shell-interpreter invocation (
bash -n,sh -n,shellcheck, evenpython3for scratch checks all returned "requires approval" with no way for me to grant it), so I could not run an automated syntax check. I instead manually re-read the full function line-by-line to confirm everyif/fi,while/done, andfor/donepair is balanced and indentation is consistent with the surrounding code (diff is a clean, additive 21-line insertion — see commit9d1e3f03). If you'd like automated verification, addingBash(bash -n:*)orBash(shellcheck:*)to--allowedToolswould let a future run confirm it directly; otherwise a quick localbash -n x-ui.shbefore merging is recommended.