I’m currently hosting this website with cloudflare CDN, so the certificate is free by default (Thanks so much Cloudflare!)
Well, but I still prefer something in control, or maybe encrypt some data or using v2ray 😆
Here is how to:
Assuming you are using MAC, so firstly, we need to install certbot:
1
brew install certbot
Then, get the cloudflare plugin installed:
1
pip3 install certbot-dns-cloudflare
All tools have been installed! well done!
To get your API key, login to your CloudFlare dashboard, go to your profile and at the bottom, click “View” next to “Global API key”.
cloudflare - my profile
api token & key
OK, next, we need to let cloudflare know who are we when we running the certbot to gain a new certificate:
1
2
3
4
5
6
7
8
# Create a folder as work folder
mkdir ~/certbot
# Create credential fileecho"# Cloudflare API credentials used by Certbot
dns_cloudflare_email = <Your Email address as username in Cloudflare>
dns_cloudflare_api_key = <Your api token>
" > ~/certbot/cloudflare.ini
Please note, this IS your password, and you SHOULD ALWAYS secure it for whatever reason:
Or if you want to renew your certificate to specific directory, you can have --config-dir, --work-dir, --logs-dir specified.
If you are going to run this in a docker image which doesn’t have any file hosted, alway running as new, you may also consider add --agree-tos and -m EMAIL for script automation, full script is like below: