Chrome and Firefox has planned to mark ALL the HTTP connection to be not secure. “How insecure it can be?” you may asked. Without HTTPS, HTTP is transferring the package in plain text, which is vulnerable to all kind of attack, especially Man-in-the-middle (MITM) attack. For example, free Wi-Fi providers can modify any HTTP pages and inject their advertisements. This can also happen when you send out data. The middle can steal and modify any data you send including user name and password.
HTTPS used to cost money and time to get a certificate and the website owner has to keep renew it every several years. This is now different because Let’s Encrypt is a free, automated, and open certificate authority (CA). They are sponsored by many big corporations to increase the security of the web.
This tutorial is going to teach you how to get certificates from Let’s Encrypt using Certbot and Cloudflare.
- Python 3 and pip installed (Basic understand of Python would be nice)
- DNS record managed by Cloudflare
Cloudflare is a CDN provider and DNS provider. I use Cloudflare personal because it is free and provides many enterprise features. I would not go too details in this tutorial. May be I will write a article about it in the future.
Certbot is a Python client that can work with ACME protocol to etches and deploys SSL/TLS certificates.
To install Certbot, please follow the instructions from the official site.
For software you select
None of the above if you want to install the certificates yourself.
To install the plugin for Cloudflare:
Run the following command to confirm you have installed correctly:
First, you need to get your API key from Cloudflare.
Click “Get your API key”
Click “View” of Global API Key
Copy your API key
cloudflare.ini and replace with your value.
Run the following command:
certonly: Certbot would not auto configure the web server for you but it only get the certificate.
renew-by-default: Certbot will setup CRON job to auto renew.
server: Only ACME v2 api can generate wildcard certificates.
dns-cloudflare: Use Cloudflare plugin
dns-cloudflare-credentials: Location of you ini file.
manual-public-ip-logging-ok: Allow Let’s Encrypt to log your ip.
m: There will be email to notify your certificate is about to expire.
no-eff-email: No email from EFF
d: Valid domain(s) for these certificate. You should replace
example.comwith you domain. This first one will be the main domain. Also,
rsa-key-size: Size of the RSA key
agree-tos: Agree term and services of Let’s Encrypt
The certificate is available at
/etc/letsencrypt/live/<Your domain> which is symlink to the latest certificate in
Note that when you try to mount this in Docker.
Then, you can use the certificate whatever you want.
Because the certificate is generated via DNS challenge, this means you can give a valid certificate for you internal domain.
Also, if you have many different services, setting up Certbot for each services may be a problem. Then, you can use a reverse proxy like nginx, Apache or traefik. If you don’t want to set it up yourself, you may consider using nginx Docker or traefik Docker which have Let’s Encrypt already setup for you..