Skip to content

Commit edd773f

Browse files
committed
fix(ingress): fix cert path for wildcard domains
Certbot stores wildcard certs without the "*." prefix (e.g. *.example.com → /etc/letsencrypt/live/example.com/). Add cert_dir_name helper to strip the prefix when constructing certificate paths in nginx config and evidence generation.
1 parent cef7489 commit edd773f

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ EOF
106106
setup_py_env
107107

108108
setup_nginx_conf() {
109+
local cert_name
110+
cert_name=$(cert_dir_name "$DOMAIN")
111+
109112
local client_max_body_size_conf=""
110113
if [ -n "$CLIENT_MAX_BODY_SIZE" ]; then
111114
client_max_body_size_conf=" client_max_body_size ${CLIENT_MAX_BODY_SIZE};"
@@ -148,8 +151,8 @@ server {
148151
server_name ${DOMAIN};
149152
150153
# SSL certificate configuration
151-
ssl_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem;
152-
ssl_certificate_key /etc/letsencrypt/live/${DOMAIN}/privkey.pem;
154+
ssl_certificate /etc/letsencrypt/live/${cert_name}/fullchain.pem;
155+
ssl_certificate_key /etc/letsencrypt/live/${cert_name}/privkey.pem;
153156
154157
# Modern SSL configuration - TLS 1.2 and 1.3 only
155158
ssl_protocols TLSv1.2 TLSv1.3;
@@ -166,7 +169,7 @@ server {
166169
# Enable OCSP stapling
167170
ssl_stapling on;
168171
ssl_stapling_verify on;
169-
ssl_trusted_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem;
172+
ssl_trusted_certificate /etc/letsencrypt/live/${cert_name}/fullchain.pem;
170173
resolver 8.8.8.8 8.8.4.4 valid=300s;
171174
resolver_timeout 5s;
172175

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ sanitize_proxy_buffers() {
112112
fi
113113
}
114114

115+
# Get the certbot certificate directory name for a domain.
116+
# Certbot stores wildcard certs without the "*." prefix:
117+
# *.example.com → /etc/letsencrypt/live/example.com/
118+
cert_dir_name() {
119+
local domain="$1"
120+
echo "${domain#\*.}"
121+
}
122+
115123
get_letsencrypt_account_path() {
116124
local base_path="/etc/letsencrypt/accounts"
117125
local api_endpoint="acme-v02.api.letsencrypt.org"

custom-domain/dstack-ingress/scripts/generate-evidences.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fi
2323
# Copy all certificate files
2424
while IFS= read -r domain; do
2525
[[ -n "$domain" ]] || continue
26-
cert_file="/etc/letsencrypt/live/${domain}/fullchain.pem"
26+
cert_file="/etc/letsencrypt/live/$(cert_dir_name "$domain")/fullchain.pem"
2727
if [ -f "$cert_file" ]; then
2828
cp "$cert_file" "cert-${domain}.pem"
2929
else

0 commit comments

Comments
 (0)