Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Domain Splitting for DuckDNS Subdomains (e.g., xray-il.duckdns.org) #50

Open
mina-atef-00 opened this issue Feb 14, 2025 · 0 comments

Comments

@mina-atef-00
Copy link

When using a full DuckDNS subdomain (such as xray-il.duckdns.org) with the x‑UI‑PRO installation script, the domain splitting logic incorrectly interprets the input. Instead of treating the entire string as the domain, the script splits it into a subdomain and main domain by assuming a format of sub.domain.tld. This results in:

  • SubDomain: xray-il
  • MainDomain: duckdns.org

Consequently, the SSL certificate is generated (via Certbot) with the cert-name duckdns.org and the Nginx configuration sets server_name to duckdns.org *.duckdns.org, which does not reflect the intended usage since I only registered xray-il.duckdns.org.

Steps to Reproduce:

  1. Register a subdomain with DuckDNS (e.g., xray-il.duckdns.org).
  2. Run the installation script and, when prompted, enter xray-il.duckdns.org as the available subdomain.
  3. Observe that the script splits the domain into xray-il and duckdns.org—leading Certbot to create certificates under /etc/letsencrypt/live/duckdns.org/ and Nginx’s server block is configured for duckdns.org *.duckdns.org.

Expected Behavior:
For a registered full subdomain like xray-il.duckdns.org, the script should treat the entire input as the main domain. This would ensure that:

  • The SSL certificate is issued for xray-il.duckdns.org (with cert-name set to the full domain).
  • The Nginx configuration uses server_name xray-il.duckdns.org; (or similarly appropriate directives).

Actual Behavior:
The script’s current logic splits the input into two parts, which:

  • Causes the certificate to be issued under duckdns.org (instead of xray-il.duckdns.org).
  • Configures Nginx for duckdns.org *.duckdns.org, which may lead to SSL validation issues and misconfiguration when accessing the panel.

Possible Solutions:

  1. Modify the Domain Parsing Logic:
    Adjust the domain extraction section in the script so that if the provided domain ends with duckdns.org (or any known third-party provider domain), the entire input is used as the main domain. For example, replacing the domain-splitting block with:
    while [[ -z $(echo "$domain" | tr -d '[:space:]') ]]; do
        read -rp $'\e[1;32;40m Enter available subdomain (sub.domain.tld): \e[0m' domain
    done
    
    domain=$(echo "$domain" | tr -d '[:space:]')
    # If the domain ends with duckdns.org, use the whole string as MainDomain.
    if [[ "$domain" =~ duckdns\.org$ ]]; then
        MainDomain="${domain}"
    else
        SubDomain=$(echo "$domain" | sed 's/^[^ ]* \|\..*//g')
        MainDomain=$(echo "$domain" | sed 's/.*\.\([^.]*\..*\)$/\1/')
        if [[ "${SubDomain}.${MainDomain}" != "${domain}" ]]; then
            MainDomain="${domain}"
        fi
    fi
    
    
  2. Provide a Flag to Bypass Domain Splitting: Offer an installation argument that allows users to bypass the automatic domain splitting for cases where they register a full subdomain (e.g., DuckDNS).

Environment:

x‑UI‑PRO version: v11.8.2 (or latest, as applicable)
Domain Provider: DuckDNS (using a full subdomain like xray-il.duckdns.org)

Additional Context: Users who utilize third-party subdomain providers (such as DuckDNS) should be able to have the script generate SSL certificates and server configurations for the exact domain they registered. The current logic assumes a standard two-level domain structure (e.g., example.com with a subdomain like panel.example.com), which does not align with full subdomains provided by services like DuckDNS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant