Skip to content

Commit 724a658

Browse files
committed
nginx: skip cert fetch on startup when cert is still valid
Avoid acme.sh hitting Let's Encrypt for every domain on each container restart. Per-domain, skip if a cert exists and is valid for more than 3 days; cron continues to handle renewals.
1 parent c755616 commit 724a658

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

app/nginx/scripts/get-certs.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ for LINE in $(cat /scripts/domains); do
2929
flags="$flags --challenge-alias $ALIAS_DOMAIN"
3030
fi
3131

32+
# skip if we already have a cert that's valid for more than 3 days; cron will handle renewals
33+
CERT_FILE=/certs/live/$folder/fullchain.pem
34+
if [[ -f $CERT_FILE ]] && openssl x509 -checkend $((3*86400)) -noout -in "$CERT_FILE" >/dev/null 2>&1; then
35+
echo "Skipping $DOMAIN: existing cert valid for >3 days"
36+
continue
37+
fi
38+
3239
mkdir -p /certs/live/$folder
3340

3441
/scripts/acme.sh/acme.sh --home /certs --issue --dns dns_aws $flags \

0 commit comments

Comments
 (0)