mkdir -p /var/www/letsencrypt
location /.well-known/acme-challenge {
root /var/www/letsencrypt;
}
certbot certonly --expand --agree-tos --text --non-interactive \
-a webroot \
--email gustavo.lichti@gmail.com \
-w /var/www/letsencrypt \
-d mercadoaventura.com.br \
-d www.mercadoaventura.com.br \
-d backoffice.mercadoaventura.com.br \
-d cep.mercadoaventura.com.br \
-d static.mercadoaventura.com.br \
-d thumbor.mercadoaventura.com.br
cat << EOF > /root/letsencrypt.sh
#!/bin/sh
certbot renew --no-self-upgrade
if [ $? -ne 0 ]
then
ERRORLOG=`tail /var/log/letsencrypt/letsencrypt.log`
echo -e "The Let's Encrypt cert has not been renewed! \n \n" \
$ERRORLOG
else
nginx -s reload
fi
exit 0
EOF
chmod +x /root/letsencrypt.sh
echo '0 0 1,15 * * /root/letsencrypt.sh' > /etc/cron.d/letsencrypt