Generating Let's Encrypt certificates - DNS challenge¶
Certificates generated by Certbot are stored on the host in the folder:
This folder is mounted in the Nginx container at:
This choice keeps the same tree as a standard Nginx installation with Certbot. It makes a possible migration to NGX Ops easier and also keeps the symbolic links created by Certbot.
Historically, certificate generation with a DNS challenge was done outside NGX Ops. You then had to configure a Certbot container manually in the stack's compose.yml file.
Since version 12.4, DNS challenge certificate generation is built directly into NGX Ops.
⚠️ Warning: only the DNS challenge has been tested in production conditions.
How it works¶
A Certbot container runs permanently alongside NGX Ops. Its role is only to handle renewal of existing certificates.
When a new certificate must be generated, NGX Ops starts an ephemeral Certbot container dedicated to this request.
The generated certificate is then kept in the shared directory:
It is thus immediately available to Nginx through the /etc/letsencrypt mount.
Requirements¶
To use this feature, you need:
- a DNS provider supported by Certbot's DNS plugins;
- an API key or token that lets Certbot modify DNS records automatically;
- a domain whose DNS management is handled by this provider.
Using a DNS API lets Certbot automatically create the records needed to validate the challenge, with no manual intervention when generating or renewing the certificate.
Configuration & usage¶
Cloudflare¶
Configuration¶
1 - Open the ./config/certbot/cloudflare/credentials.ini file
2 - In the file, replace YOUR-API-TOKEN with your API key and save the changes.
3 - In NGX Ops, go to ADMINISTRATION / Configuration, then to the Certbot - DNS challenge tab, adapt the configuration below and click Save.
enable: true
provider: cloudflare
email: [email protected]
credentials_host_path: /containers/nginx/config/certbot/cloudflare/credentials.ini
certs_host_path: /containers/nginx/certificats/certbot
Variables containing paths are locations on the Docker host.
4 - Then go to the SSL / Certbot page and start the DNS CHALLENGE container in charge of renewal.
Request a certificate¶
To request a certificate, go to the Issue one or more certificates area.
Enter the DNS names to include in the certificate, for example:
You can enter several DNS names separated by a space.
Then click Generate.
Wait a few seconds while Certbot performs the DNS challenge and issues the certificate.
Once the operation is done, the certificate is available in NGX Ops and can be used in your virtual hosts.
