web: add builtin Let's Encrypt support

This commit is contained in:
Saúl Ibarra Corretgé
2018-11-07 11:23:08 +01:00
parent 2115bc0ed3
commit f61ef3f093
11 changed files with 78 additions and 15 deletions

View File

@@ -8,12 +8,26 @@ mkdir -p \
/var/tmp/nginx
# generate keys (maybe)
if [[ -f /config/keys/cert.key && -f /config/keys/cert.crt ]]; then
echo "using keys found in /config/keys"
if [[ $ENABLE_LETSENCRYPT -eq 1 ]]; then
if [[ ! -f /etc/letsencrypt/live/$LETSENCRYPT_DOMAIN/fullchain.pem ]]; then
certbot certonly \
--noninteractive \
--standalone \
--preferred-challenges http \
-d $LETSENCRYPT_DOMAIN \
--agree-tos \
--email $LETSENCRYPT_EMAIL
cp /defaults/letsencrypt-renew /etc/cron.monthly/
fi
else
echo "generating self-signed keys in /config/keys, you can replace these with your own keys if required"
SUBJECT="/C=US/ST=TX/L=Austin/O=jitsi.org/OU=Jitsi Server/CN=*"
openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT"
# use self-signed certs
if [[ -f /config/keys/cert.key && -f /config/keys/cert.crt ]]; then
echo "using keys found in /config/keys"
else
echo "generating self-signed keys in /config/keys, you can replace these with your own keys if required"
SUBJECT="/C=US/ST=TX/L=Austin/O=jitsi.org/OU=Jitsi Server/CN=*"
openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT"
fi
fi
# copy config files
@@ -22,7 +36,7 @@ if [[ ! -f /config/nginx/nginx.conf ]]; then
fi
if [[ ! -f /config/nginx/ssl.conf ]]; then
cp /defaults/ssl.conf /config/nginx/ssl.conf
tpl /defaults/ssl.conf > /config/nginx/ssl.conf
fi
if [ ! -f "/config/nginx/dhparams.pem" ]; then