Describe the bug
When using the "Get SSL for IP Address" feature (option 6 in SSL Certificate Management), the script detects the server IP using external services like api.ipify.org. However, if the server has a proxy configured via environment variables (ALL_PROXY, http_proxy, https_proxy), the detected IP is the proxy's exit IP, not the actual server IP.
This is particularly problematic in countries with restricted internet access (like Iran), where users must configure a proxy to access external services like Let's Encrypt. The proxy causes curl to return the proxy's IP address instead of the server's actual public IP.
Example scenario:
- Server actual IP:
1.1.1.1
- Proxy configured:
export ALL_PROXY=socks5h://127.0.0.1:1080
- Proxy exit IP:
2.2.2.2
- Result: Certificate is issued for
2.2.2.2 (proxy IP) instead of 1.1.1.1 (server IP)
How to repeat the problem?
- Configure a SOCKS5 proxy on the server:
export ALL_PROXY=socks5h://127.0.0.1:1080
- Run
x-ui and navigate to menu option 19 (SSL Certificate Management)
- Select option
6 (Get SSL for IP Address)
- Observe the detected IP - it shows the proxy's exit IP, not the server's actual IP
- Certificate is issued for the wrong IP
Expected action
The script should:
- First try to detect the server IP from local network interfaces (e.g.,
ip -4 addr show scope global) which doesn't use proxy
- Then fall back to external services if local detection fails
- Always display the detected IP and allow the user to manually correct it if wrong
Received action
- The script only uses external curl-based services (
api.ipify.org, etc.) to detect IP
- When proxy is configured, these services return the proxy's IP
- User has no opportunity to correct the detected IP before certificate issuance
- Certificate is issued for the wrong IP, causing SSL failures
Proposed Fix
Modify the IP detection logic in x-ui.sh to:
-
Add local interface detection first (proxy-independent):
if command -v ip >/dev/null 2>&1; then
ip=$(ip -4 addr show scope global | grep -oP 'inet \K[\d.]+' | head -n1)
fi
-
Keep external services as fallback with multiple endpoints for reliability
-
Add interactive confirmation allowing users to override the detected IP:
echo "Server IP detected: ${ip}"
read -rp "Press Enter to use this IP, or type a different IP: " user_input
if [ -n "$user_input" ]; then
ip="$user_input"
fi
Affected Functions
ssl_cert_issue_for_ip() - Line ~1174
check_config() - Line ~333
SSH_port_forwarding() - Line ~2095
Additional Context
This issue affects users in regions with restricted internet who rely on proxies to access:
- Let's Encrypt ACME servers
- External IP detection services
- Package repositories
The fix ensures the script works correctly regardless of proxy configuration while still maintaining full functionality for users without proxy restrictions.
3x-ui Version
2.8.11 (current development)
Xray-core Version
N/A (script-level issue)
Checklist
Describe the bug
When using the "Get SSL for IP Address" feature (option 6 in SSL Certificate Management), the script detects the server IP using external services like
api.ipify.org. However, if the server has a proxy configured via environment variables (ALL_PROXY,http_proxy,https_proxy), the detected IP is the proxy's exit IP, not the actual server IP.This is particularly problematic in countries with restricted internet access (like Iran), where users must configure a proxy to access external services like Let's Encrypt. The proxy causes
curlto return the proxy's IP address instead of the server's actual public IP.Example scenario:
1.1.1.1export ALL_PROXY=socks5h://127.0.0.1:10802.2.2.22.2.2.2(proxy IP) instead of1.1.1.1(server IP)How to repeat the problem?
export ALL_PROXY=socks5h://127.0.0.1:1080x-uiand navigate to menu option19(SSL Certificate Management)6(Get SSL for IP Address)Expected action
The script should:
ip -4 addr show scope global) which doesn't use proxyReceived action
api.ipify.org, etc.) to detect IPProposed Fix
Modify the IP detection logic in x-ui.sh to:
Add local interface detection first (proxy-independent):
Keep external services as fallback with multiple endpoints for reliability
Add interactive confirmation allowing users to override the detected IP:
Affected Functions
ssl_cert_issue_for_ip()- Line ~1174check_config()- Line ~333SSH_port_forwarding()- Line ~2095Additional Context
This issue affects users in regions with restricted internet who rely on proxies to access:
The fix ensures the script works correctly regardless of proxy configuration while still maintaining full functionality for users without proxy restrictions.
3x-ui Version
2.8.11 (current development)
Xray-core Version
N/A (script-level issue)
Checklist