์๋๋ก์ง ๋์ค Cloudflare DNS Let's Encrypt WildCard SSL ์ ์ฉ
ํ์ด์ง ์ ๋ณด
๋ณธ๋ฌธ
sudo -i
cd ~
wget https://github.com/Neilpang/acme.sh/archive/master.tar.gz
tar xvf master.tar.gz
cd acme.sh-master
ย
./acme.sh --install --nocron --home /usr/local/share/acme.sh --accountemail "์ด๋ฉ์ผ" --server letsencrypt
ย
cd /usr/local/share/acme.sh/
ย
export CF_Key="๊ธ๋ก๋ฒ API ํค"
export CF_Email="์ด๋ฉ์ผ"
export CERT_DNS="dns_cf"
ย
./acme.sh --issue -d *.๋๋ฉ์ธ -d ๋๋ฉ์ธ --dns $CERT_DNS --cert-file /usr/syno/etc/certificate/system/default/cert.pem --key-file /usr/syno/etc/certificate/system/default/privkey.pem --fullchain-file /usr/syno/etc/certificate/system/default/fullchain.pem --reloadcmd "/usr/syno/sbin/synoservicectl --reload nginx" --dnssleep 30 --force --server letsencrypt
ย
export CERT_FOLDER="$(find /usr/syno/etc/certificate/_archive/ -maxdepth 1 -mindepth 1 -type d)"
export CERT_DNS="dns_cf"
ย
./acme.sh --issue -d *.๋๋ฉ์ธ -d ๋๋ฉ์ธ --dns "$CERT_DNS" --cert-file "$CERT_FOLDER/cert.pem" --key-file "$CERT_FOLDER/privkey.pem" --fullchain-file "$CERT_FOLDER/fullchain.pem" --capath "$CERT_FOLDER/chain.pem" --reloadcmd "/usr/syno/sbin/synoservicectl --reload nginx" --dnssleep 30 --force --server letsencrypt
ย
์ ์ดํ > ์์ ์ค์ผ์ค๋ฌ > ์์ฝ๋ ์์ > ์ฌ์ฉ์ ์ ์ ์คํฌ๋ฆฝํธ
ย
# Note: The $CERT_FOLDER must be hardcoded here since the running environment is unknown. Don't blindly copy&paste!
# if you used the normal method the certificate will be installed in the system/default directory CERTDIR="system/default"
# if you used the alternative method it is copied to an unknown path, change the following example to the output of the creation process and uncomment.
#CERTDIR="_archive/AsDFgH"
# do not change anything beyond this line!
CERTROOTDIR="/usr/syno/etc/certificate"
PACKAGECERTROOTDIR="/usr/local/etc/certificate"
FULLCERTDIR="$CERTROOTDIR/$CERTDIR"
# renew certificates, this used to be explained as a custom cronjob but works just as well within this script according to the output of the task.
/usr/local/share/acme.sh/acme.sh --cron --home /usr/local/share/acme.sh/
# find all subdirectories containing cert.pem files
PEMFILES=$(find $CERTROOTDIR -name cert.pem)
if [ ! -z "$PEMFILES" ]; then
ย ย ย ย for DIR in $PEMFILES; do
ย ย ย ย ย ย ย ย # replace the certificates, but never the ones in the _archive folders as those are all the unique
ย ย ย ย ย ย ย ย # certificates on the system.
ย ย ย ย ย ย ย ย if [[ $DIR != *"/_archive/"* ]]; then
ย ย ย ย ย ย ย ย ย ย ย ย rsync -avh "$FULLCERTDIR/" "$(dirname $DIR)/"
ย ย ย ย ย ย ย ย fi
ย ย ย ย done
fi
# reload
/usr/syno/sbin/synoservicectl --reload nginx
# update and restart all installed packages
PEMFILES=$(find $PACKAGECERTROOTDIR -name cert.pem)
if [ ! -z "$PEMFILES" ]; then
ย ย ย ย for DIR in $PEMFILES; do
ย ย ย ย ย ย ย ย #active directory has it's own certificate so we do not update that package
ย ย ย ย ย ย ย ย if [[ $DIR != *"/ActiveDirectoryServer/"* ]]; then
ย ย ย ย ย ย ย ย ย ย ย ย rsync -avh "$FULLCERTDIR/" "$(dirname $DIR)/"
ย ย ย ย ย ย ย ย ย ย ย ย /usr/syno/bin/synopkg restart $(echo $DIR | awk -F/ '{print $6}')
ย ย ย ย ย ย ย ย fi
ย ย ย ย done
fi
๋๊ธ๋ชฉ๋ก
๋ฑ๋ก๋ ๋๊ธ์ด ์์ต๋๋ค.
