1
0
Fork 0

Some refactory to support letsencrypt

This commit is contained in:
Joao M 2022-08-15 04:31:50 +00:00
parent bdc97fa10d
commit 9fa9dc9841
15 changed files with 207 additions and 145 deletions

View file

@ -1,3 +0,0 @@
# Certs Folder
Docker Easy HAProxy will save the SSL Certs here.

View file

@ -2,16 +2,37 @@
@todo
mkdir -p /var/log/letsencrypt
ln -sf /dev/stdout /var/log/letsencrypt/letsencrypt.log
certbot certonly \
--standalone \
--preferred-challenges http \
--http-01-port 2080 \
--agree-tos \
--issuance-timeout 90 \
--no-eff-email \
--non-interactive \
--max-log-backups=0 \
--post-hook "/scripts/certbot_to_haproxy.sh && systemctl reload haproxy.service"
-d dev.globalnetguide.com -d other.domain.com --email info@xpto.us
REQUEST_CERTS=""
RENEW_CERTS=""
for domain in $(cat /scripts/letsencrypt_hosts.txt); do
if [ ! -f "/etc/haproxy/certs/$domain.pem" ]; then
REQUEST_CERTS="$REQUES_CERTS -d $domain"
continue
fi
if [[ $(find "/etc/haproxy/certs/$domain.pem" -mtime +30 -print) ]]; then
RENEW_CERTS="$RENEW_CERTS -d $domain"
fi
done
if [ -n "$REQUEST_CERTS" ]; then
certbot certonly \
--standalone \
--preferred-challenges http \
--http-01-port 2080 \
--agree-tos \
--issuance-timeout 90 \
--no-eff-email \
--non-interactive \
--max-log-backups=0 \
--post-hook "/scripts/certbot_to_haproxy.sh" \
$REQUEST_CERTS --email info@xpto.us
fi
if [ -n "$RENEW_CERTS" ]; then
certbot renew --post-hook "/scripts/certbot_to_haproxy.sh"
fi

View file

@ -9,3 +9,5 @@ for CERTIFICATE in `find /etc/letsencrypt/live/* -type d`; do
# Combine certificate and private key to single file
cat /etc/letsencrypt/live/$CERTIFICATE/fullchain.pem /etc/letsencrypt/live/$CERTIFICATE/privkey.pem > /etc/haproxy/certs/$CERTIFICATE.pem
done
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -x /var/run/haproxy.sock -sf $(cat /run/haproxy.pid) &