Automate Wildcard SSL on Nginx with Certbot & Cloudflare: A 2025 Guide
Secure your Nginx server with automated wildcard SSL certificates. This guide details using Certbot and Cloudflare's DNS-01 challenge for seamless, secure subdomain management.

In the modern web, HTTPS is non-negotiable. It secures user data, builds trust, and is a key factor in search engine rankings. While obtaining an SSL certificate for a single domain is straightforward with Let's Encrypt and Certbot, managing certificates for a growing number of subdomains (www
, api
, blog
, status
, etc.) can quickly become a manual, error-prone chore.
The definitive solution is a wildcard certificate, which secures your root domain and all its subdomains (*.yourdomain.com
) with a single certificate.
This guide provides a comprehensive, step-by-step walkthrough for setting up a fully automated wildcard SSL certificate on an Ubuntu server running Nginx. We will leverage the power of Certbot, the security of the Cloudflare API, and the robust DNS-01 challenge method. By the end of this tutorial, you will have a "set-and-forget" SSL system that automatically renews itself, freeing you to focus on development.
Why the DNS-01 Challenge is Essential
To issue a certificate, Let's Encrypt must verify that you control the domain. The two most common verification methods, or "challenges," are HTTP-01
and DNS-01
.