This will configure an Asustor NAS to use a Let's Encrypt certificate without exposing it to the internet.
To achieve this, we use Certbot with the DNS-01 challenge via Cloudflare.
I'm placing my configuration in
/volume1/system
. Feel free to change this to whatever location you prefer.
- Set up Cloudflare credentials.
mkdir /volume1/system/letsencrypt
touch /volume1/system/letsencrypt/cloudflare.ini
chown root:root /volume1/system/letsencrypt
chmod 700 /volume1/system/letsencrypt
chmod 600 /volume1/system/letsencrypt/cloudflare.ini
Add your Cloudflare API key to cloudflare.ini
as described here:
https://certbot-dns-cloudflare.readthedocs.io/en/stable/#credentials
-
Place
install.sh
andadm-deploy.sh
in/volume1/system/letsencrypt
-
Run
install.sh
to setup pip and certbot-dns-cloudflare. -
Link
adm-deploy.sh
to letsencrypt deploy hook.
ln -s /volume1/system/letsencrypt/adm-deploy.sh /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy/
- Generate the certificate.
Make sure to changenas.mydomain.com
inadm-deploy.sh
and in the below command to your FQDN
certbot certonly --config-dir=/volume0/usr/builtin/etc/letsencrypt \
--dns-cloudflare --dns-cloudflare-credentials /volume1/system/letsencrypt/cloudflare.ini \
--preferred-challenges dns-01 \
-d nas.mydomain.com
- Add renew to crontab, run
crontab -e
as root.
@reboot /volume1/system/letsencrypt/install.sh && /usr/bin/certbot --config-dir=/volume0/usr/builtin/etc/letsencrypt renew
0 6 * * * /usr/bin/certbot --config-dir=/volume0/usr/builtin/etc/letsencrypt renew
Working as expected thanks ! :)
To note; the path
/volume1/system
is not existing on my asustor.Dropped files to
/volume0/usr/builtin/etc/letsencrypt
for the moment.