Skip to content

Commit a794fcc

Browse files
committed
fix(namecheap): use full app domain for CNAME instead of underscore wildcard
Namecheap's DNS servers don't serve CNAME records pointing to underscore-prefixed domains (e.g., _.dstack-pha-prod9.phala.network). The record appears in the Namecheap API but isn't visible in public DNS queries. This fix detects when DNS_PROVIDER=namecheap and GATEWAY_DOMAIN starts with an underscore, then substitutes the full app-specific domain instead: Before: _.dstack-pha-prod9.phala.network After: {app_id}-{port}.dstack-pha-prod9.phala.network Both resolve to the same IP, and the TXT records handle app routing, so functionality is preserved. Tested with hermes.teleport.computer - custom domain now resolves correctly.
1 parent 386a2e9 commit a794fcc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

custom-domain/dstack-ingress/scripts/entrypoint.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,27 @@ EOF
179179

180180
set_alias_record() {
181181
local domain="$1"
182+
local cname_target="$GATEWAY_DOMAIN"
183+
184+
# Namecheap DNS servers don't serve CNAME records pointing to underscore-prefixed domains.
185+
# The record appears in the Namecheap API but isn't visible in public DNS.
186+
# Workaround: use the full app-specific domain instead (resolves to the same IP).
187+
if [[ "$DNS_PROVIDER" == "namecheap" && "$cname_target" == _* ]]; then
188+
local app_id
189+
if [[ -S /var/run/dstack.sock ]]; then
190+
app_id=$(curl -s --unix-socket /var/run/dstack.sock http://localhost/Info | jq -j .app_id)
191+
else
192+
app_id=$(curl -s --unix-socket /var/run/tappd.sock http://localhost/prpc/Tappd.Info | jq -j .app_id)
193+
fi
194+
# Replace _.domain with appid-port.domain
195+
cname_target="${app_id}-${PORT}.${cname_target#_.}"
196+
echo "Namecheap workaround: using $cname_target instead of $GATEWAY_DOMAIN"
197+
fi
198+
182199
echo "Setting alias record for $domain"
183200
dnsman.py set_alias \
184201
--domain "$domain" \
185-
--content "$GATEWAY_DOMAIN"
202+
--content "$cname_target"
186203

187204
if [ $? -ne 0 ]; then
188205
echo "Error: Failed to set alias record for $domain"

0 commit comments

Comments
 (0)