Last active
July 24, 2025 14:57
-
-
Save telf3/ae1bae681d10ce37ec5645d362fcf9ef to your computer and use it in GitHub Desktop.
Revisions
-
telf3 revised this gist
Jul 24, 2025 . 2 changed files with 13 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,38 @@ 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.* 1. Set up Cloudflare credentials. ```shell 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 2. Place `install.sh` and `adm-deploy.sh` in `/volume1/system/letsencrypt` 3. Run `install.sh` to setup pip and certbot-dns-cloudflare. 3. Link `adm-deploy.sh` to letsencrypt deploy hook. ```shell ln -s /volume1/system/letsencrypt/adm-deploy.sh /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy/ ``` 4. Generate the certificate. *Make sure to change `nas.mydomain.com` in `adm-deploy.sh` and in the below command to your FQDN* ```shell 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 ``` 5. Add renew to crontab, run `crontab -e` as root. ```shell @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 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,4 +11,4 @@ TARGET=/volume0/usr/etc/lighttpd # ADM lighttpd web server ssl cert target direc cat $SOURCE/privkey.pem $SOURCE/cert.pem > $SOURCE/lighttpd.pem cp -Lfv $SOURCE/lighttpd.pem $TARGET/lighttpd.pem /etc/init.d/S41lighttpd restart -
telf3 revised this gist
Oct 29, 2024 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ #!/usr/bin/env bash # Asustor NAS Let's Encrypt certificate renewal deploy shell script. # Place in this directory to run on successful renwal: # /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy # Certbot docs: https://certbot.eff.org/docs/using.html SOURCE=/volume0/usr/builtin/etc/letsencrypt/live/nas.domain.com # letsencrypt certificate TARGET=/volume0/usr/builtin/etc/certificate cat $SOURCE/privkey.pem $SOURCE/cert.pem > $SOURCE/ssl.pem cp -Lfv $SOURCE/cert.pem $TARGET/ssl.crt cp -Lfv $SOURCE/privkey.pem $TARGET/ssl.key cp -Lfv $SOURCE/ssl.pem $TARGET/ssl.pem pkill nginx sleep 1 /volume0/usr/builtin/sbin/nginx -c /volume0/usr/builtin/etc/nginx_reverse_proxy/nginx.conf -
telf3 revised this gist
Jul 8, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ # /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy # Certbot docs: https://certbot.eff.org/docs/using.html SOURCE=/volume0/usr/builtin/etc/letsencrypt/live/nas.domain.com # letsencrypt certificate TARGET=/volume0/usr/etc/lighttpd # ADM lighttpd web server ssl cert target directory cat $SOURCE/privkey.pem $SOURCE/cert.pem > $SOURCE/lighttpd.pem -
telf3 revised this gist
Jul 6, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ This will configure an Asustor NAS to use letsencrypt certificate without exposing it to the internet. To achieve this we use certbot with DNS-01 challenge to Cloudflare. 1. Setup cloudflare secret. -
telf3 revised this gist
Jul 6, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ https://certbot-dns-cloudflare.readthedocs.io/en/stable/#credentials 3. Run install.sh to setup pip and certbot-dns-cloudflare. 3. Link script to letsencrypt deploy hook. ```shell ln -s /volume1/system/letsencrypt/adm-deploy.sh /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy/ ``` -
telf3 revised this gist
Jul 6, 2024 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,7 @@ The goal is to configure Asustor NAS to use letsencrypt certificate without exposing it to the internet. To achieve this we use certbot with DNS-01 challenge to Cloudflare. 1. Setup cloudflare secret. ```shell mkdir /volume1/system/letsencrypt touch /volume1/system/letsencrypt/cloudflare.ini @@ -14,7 +12,14 @@ chmod 600 /volume1/system/letsencrypt/cloudflare.ini Add the Cloudflare API key in this file: https://certbot-dns-cloudflare.readthedocs.io/en/stable/#credentials 2. Place install.sh and adm.deploy.sh in `/volume1/system/letsencrypt` 3. Run install.sh to setup pip and certbot-dns-cloudflare. 3. Link script to lets encrypts deploy hook. ```shell ln -s /volume1/system/letsencrypt/adm-deploy.sh /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy/ ``` 4. Generate certificate. ```shell @@ -24,7 +29,8 @@ certbot certonly --config-dir=/volume0/usr/builtin/etc/letsencrypt \ -d nas.mydomain.com ``` 5. Add renew to crontab `/var/spool/cron/crontabs/root` ```shell @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 ``` -
telf3 revised this gist
Jul 6, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Asustor NAS Let's Encrypt certificate renewal deploy shell script. # Place in this directory to run on successful renwal: # /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy # Certbot docs: https://certbot.eff.org/docs/using.html -
telf3 revised this gist
Jul 6, 2024 . 1 changed file with 14 additions and 27 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,14 @@ #!/usr/bin/env bash # An asustor NAS Let's Encrypt certificate renewal deploy shell script. # Place in this directory to run on successful renwal: # /volume0/usr/builtin/etc/letsencrypt/renewal-hooks/deploy # Certbot docs: https://certbot.eff.org/docs/using.html SOURCE=/volume0/usr/builtin/etc/letsencrypt/live/tor.telf.se # letsencrypt certificate TARGET=/volume0/usr/etc/lighttpd # ADM lighttpd web server ssl cert target directory cat $SOURCE/privkey.pem $SOURCE/cert.pem > $SOURCE/lighttpd.pem cp -Lfv $SOURCE/lighttpd.pem $TARGET/lighttpd.pem /etc/init.d/S41lighttpd restart -
telf3 revised this gist
Mar 17, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ chmod 600 /volume1/system/letsencrypt/cloudflare.ini Add the Cloudflare API key in this file: https://certbot-dns-cloudflare.readthedocs.io/en/stable/#credentials 3. Place adm-deploy.sh in `/volume0/usr/builtin/etc/letsencrypt/renew-hooks` 4. Generate certificate. ```shell -
telf3 renamed this gist
Mar 17, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
telf3 created this gist
Mar 17, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/bin/sh # An asustor NAS Let's Encrypt certificate renewal deploy shell script. # https://github.com/bebo-dot-dev/asustor-certbot/ # Dependencies: # A certbot --config-dir/renewal-hooks/deploy directory to host this script # # When this shell script is present in the certbot --config-dir/renewal-hooks/deploy, it will be called # by certbot upon successful renewal only # This script can be used to automate actions that need to be performed upon post renewal success # i.e. certificate copy / service restart etc # # certbot docs are here: https://certbot.eff.org/docs/using.html CONFIG_DIR=/volume0/usr/builtin/etc/letsencrypt # the certbot --config-dir SOURCE_CERT=/live/nas.mydomain.com # a source letsencrypt certificate to perform actions with ADM_TARGET=/volume0/usr/etc/lighttpd # the ADM lighttpd web server ssl cert target directory ADM_WEB_SERVICE=/etc/init.d/S41lighttpd # the ADM lighttpd service control script #create a lighttpd "compatible" cert by combining the private key and the cert together and #then update the lighttpd ssl cert with that cat $CONFIG_DIR$SOURCE_CERT/privkey.pem $CONFIG_DIR$SOURCE_CERT/cert.pem > $CONFIG_DIR$SOURCE_CERT/lighttpd.pem cp -L -f $CONFIG_DIR$SOURCE_CERT/lighttpd.pem $ADM_TARGET/lighttpd.pem #restart lighttpd $ADM_WEB_SERVICE restart This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ The goal is to configure Asustor NAS to use letsencrypt certificate without exposing it to the internet. To achieve this we use certbot with DNS-01 challenge to Cloudflare. 1. Run install.sh to install pip and certbot-dns-cloudflare. 2. Setup cloudflare secret. ```shell 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 the Cloudflare API key in this file: https://certbot-dns-cloudflare.readthedocs.io/en/stable/#credentials 3. Place adm-deploy.sh in /volume0/usr/builtin/etc/letsencrypt/renew-hooks 4. Generate certificate. ```shell 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 ``` 5. Add renew to crontab: ```shell echo "0 6 * * * /usr/bin/certbot --config-dir=/volume0/usr/builtin/etc/letsencrypt renew" | tee -a /var/spool/cron/crontabs/root ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ #!/bin/sh python3 -m ensurepip python3 -m pip install --upgrade pip python3 -m pip -V pip3 install certbot-dns-cloudflare ln -s /volume1/.@plugins/AppCentral/python3/bin/certbot /usr/bin/certbot