Go application to automatically obtain and renew multiple Let's Encrypt certificates using Certbot, configured via a TOML file. Designed to run alongside a reverse proxy like Nginx.
- Automated certificate acquisition via Certbot.
- Automated certificate renewal via Certbot through Go cron scheduler.
- Declarative configuration using a TOML file (
config.toml). - Support for different Certbot authenticators (
webroot,dns-cloudflare,dns-duckdns). - Customizable Certbot arguments per certificate.
- Leveled logging controllable via flags or environment variables.
- Designed for containerized environments (Docker).
- Open to extensibility for additional features, flags and authenticator plugins.
Important
Since certbot-manager leverages Certbot, you must first install Certbot separately on your system if running
standalone.
See Certbot Installation for instructions.
- Download the latest binary from the Releases page.
- Create your
config.tomlfile (see Configuration section below and the detailed Configuration Details document). - Ensure required environment variables (like
DUCKDNS_TOKEN) are set if needed. - Run the binary:
# Example: Use a config file in the current directory ./certbot-manager --config=./config.toml --log-level=debug # Example: Specify a different path ./certbot-manager -c /etc/certbot-manager/config.toml
This application is primarily intended to be run as a Docker container using Docker Compose, alongside your web server/proxy container. The Certbot dependency is included in the Docker image.
services:
certbot-manager:
image: ghcr.io/jcbasso/certbot-manager:latest
container_name: certbot-manager
env_file:
- .env
volumes:
- ./config.toml:/app/config.toml:ro
- letsencrypt_data:/etc/letsencrypt
- acme_challenge_webroot:/var/www/acme-challenge
restart: unless-stopped
volumes:
letsencrypt_data:
acme_challenge_webroot:Steps:
- Create your
config.tomlfile in the same directory as yourdocker-compose.yml(or adjust the volume mount). See the Configuration summary below and the detailed Configuration Details document. - If using DNS authenticators requiring secrets (like DuckDNS), create a
.envfile in your project root containing the secrets (e.g.,DUCKDNS_TOKEN=your_secret_token). - Ensure your
docker-compose.ymlcorrectly defines thecertbot-managerservice and shared volumes. - Run
docker compose up -dto start the service (add--buildif building locally).
certbot-manager is configured primarily through a TOML file (e.g., config.toml). Settings can also be overridden by command-line arguments and environment variables. The order of precedence is: Command-Line Flags > Environment Variables > Config File > Built-in Defaults.
The config.toml file allows you to define global settings and then specify individual certificates to manage.
Example config.toml Structure:
# Global settings that apply to all certificates unless overridden
[globals]
email = "admin@example.com"
renewal_cron = "0 0 0,12 * * *"
cmd = "certonly"
# Define one or more certificates to manage
[[certificate]]
domains = ["example.com", "www.example.com"]
authenticator = "webroot"
webroot_path = "/var/www/acme-challenge"
[[certificate]]
domains = ["my-domain.duckdns.org"]
authenticator = "dns-duckdns"
duckdns_token = "123456-78910"
dns_propagation_seconds = "60"
args = "--vvv --nginx"Key Configuration Sections:
[globals]: Define default settings here, such as your primary email address for Let's Encrypt, whether to use the staging (test) or production environment, the default Certbot command (likecertonly), and the cron schedule for renewal checks.[[certificate]]: Create one of these sections for each certificate you need.- List the
domainsthe certificate will cover. - Specify the
authenticatormethod Certbot should use to verify domain ownership (e.g.,webrootordns-duckdns). - You can also override any global settings specifically for this certificate or add custom
argsfor fine-grained control over Certbot's behavior.
- List the
Tip
- The example above is a simplified overview. For a complete list of all configuration options, their descriptions, default values, and details on using command-line flags and environment variables, please refer to the Configuration Details document.
- A more comprehensive example configuration file is available at config.toml.
The authenticator field in the [[certificate]] section of your config.toml determines how domain ownership is
verified:
webroot(Default): Uses the HTTP-01 challenge. Requires your web server (e.g., Nginx) to be configured to serve files from thewebroot_pathfor the/.well-known/acme-challenge/URI.dns-cloudflare: Uses the DNS-01 challenge.dns-duckdns: Uses the DNS-01 challenge via the infinityofspace/certbot_dns_duckdns plugin. Requires theDUCKDNS_TOKENenvironment variable to be set.
- Requires Go version specified in go.mod.
- Follow git branching model & release specifications.
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.