# root's required due to lighttpd perms and pihole struct
sudo -i
curl https://get.acme.sh | sh -s [email protected]
# Alternatively, clone and exec locally.
mkdir -p /etc/lighttpd/certs/pihole.mylab.domain/
cd /etc/lighttpd/certs/pihole.mylab.domain
# Ensure a high-enough entropy
openssl dhparam -out dhparam.pem -dsaparam 4096
export CF_Token="sdfsdfsdfljlbjkljlkjsdfoiwje"
export CF_Account_ID="xxxxxxxxxxxxx"
export CF_Zone_ID="xxxxxxxxxxxxx"
./acme.sh --issue --dns dns_cf -d pihole.mylab.domain
Edit the lighttpd
proxy config (vim /etc/lighttpd/external.conf
):
# external.conf
$HTTP["host"] == "pihole.mylab.domain" {
# Ensure the Pi-hole Block Page knows that this is not a blocked domain
setenv.add-environment = ("fqdn" => "true")
# Enable the SSL engine with a LE cert, only for this specific host
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/certs/pihole.mylab.domain/ssl.pem"
ssl.ca-file = "/etc/lighttpd/certs/pihole.mylab.domain/ca.cer"
ssl.dh-file = "/etc/lighttpd/certs/pihole.mylab.domain/dhparam.pem"
ssl.honor-cipher-order = "enable"
ssl.cipher-list = "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"
ssl.use-compression = "disable"
ssl.use-sslv2 = "disable"
ssl.use-sslv3 = "disable"
}
# Redirect HTTP to HTTPS
$HTTP["scheme"] == "http" {
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
}
}
Create a post-renew install hook - vim /root/.acme.sh/pihole/hook.sh
#!/bin/bash
dom="pihole.mylab.domain"
dest="/etc/lighttpd/certs/pihole.mylab.domain" #lighttpd ssl folder created in step one
croot="/root/.acme.sh/${dom}" #acme.sh root path for your domain
sslfile="${dest}/ssl.pem"
certfile="${croot}/${dom}.cer"
keyfile="${croot}/${dom}.key"
echo "Copying certificate"
/bin/cat "${certfile}" "${keyfile}" > "${sslfile}"
echo "Settings perms"
chown root:root /etc/lighttpd/certs/pihole.mylab.domain/ssl.pem
chmod 400 /etc/lighttpd/certs/pihole.mylab.domain/ssl.pem
echo "Restarting lighttpd service"
/bin/systemctl restart lighttpd
Make the hook executable:
chmod +x /root/.acme.sh/pihole/hook.sh
Deploy certs and wire things up:
acme.sh --installcert -d pihole.mylab.domain \
--capath /etc/lighttpd/certs/pihole.mylab.domain/ca.cer \
--reloadcmd '/root/.acme.sh/pihole/hook.sh'
# verify autorenew cronjob has been installed
crontab -l
curl https://get.acme.sh | sh -s [email protected]
# change directory
cd .acme.sh
# optional - set letsencrypt as the default CA
acme.sh --set-default-ca --server letsencrypt
# set API key and email login env variables:
export CF_Key="Cloudflare_Global_API_Key"
export CF_Email="Your_Email_Accessing_Cloudflare"
# issue the desired certificate and deploy on keystore
./acme.sh --issue --dns dns_cf -d cloudkey.example.com
./acme.sh --deploy -d cloudkey.example.com --deploy-hook unifi
# verify autorenew cronjob has been installed
crontab -l
WIP