Post

She May Come To Regret Asking

She May Come To Regret Asking

She May Come To RegretAsking

INTRODUCTION

Imagine you’re a seasoned sysadmin, comfortably managing a modest homelab that runs a handful of containers, a reverse proxy, and a few static sites. You’ve heard the buzz about automating SSL certificate renewal, about “one‑liner” Docker Compose updates, and about using Let’s Encrypt in a self‑hosted environment. You decide to ask a simple question on a community forum: “How do I automate certbot renewals for my Docker‑based services?”

What follows is a classic DevOps rite of passage. Within weeks you’ll be knee‑deep in log files, wrestling with rate‑limited API calls, and watching half of your homelab go offline because a single service update cascaded into a chain reaction of restarts. The phrase “She May Come To Regret Asking” captures that moment when curiosity meets the unforgiving reality of infrastructure complexity.

This guide is crafted for experienced DevOps engineers, homelab enthusiasts, and anyone who’s ever dabbled in self‑hosted automation only to discover that the learning curve is steeper than anticipated. We’ll dissect the underlying concepts, walk through a production‑grade setup, and arm you with practical troubleshooting tactics. By the end, you’ll understand not just how to automate certificates, but why each step matters, what pitfalls to anticipate, and how to design resilient, maintainable configurations that won’t force you to watch your services crash in real time.

Key takeaways include:

  • A clear explanation of the toolchain (Docker Compose, Certbot, Nginx Proxy Manager) and its role in modern homelab networking.
  • Step‑by‑step installation and configuration instructions that avoid common pitfalls.
  • Security hardening techniques to protect private keys and internal services.
  • Real‑world examples of scaling, monitoring, and backup strategies.
  • A concise troubleshooting cheat sheet for the most frequent failure modes.

Whether you’re building a personal lab or managing a small production‑grade deployment, the principles outlined here will help you avoid the “regret” that often accompanies a premature question. Let’s dive into the technology that makes homelab automation both powerful and precarious.


UNDERSTANDING THE TOPIC

What is the toolchain?

At its core, the scenario revolves around Docker Compose as the orchestration layer, Certbot (or an equivalent ACME client) for obtaining and renewing TLS certificates, and a reverse proxy such as Nginx Proxy Manager or Traefik to route traffic to containers. These components are staples of modern self‑hosted infrastructures because they enable: - Isolation – each service runs in its own container, reducing host‑level conflicts.

  • Automation – scripts can spin up, tear down, or update services without manual intervention.
  • TLS termination – external traffic is encrypted before it reaches the application, preserving end‑to‑end security.

The typical workflow looks like this:

  1. A DNS record points to the homelab’s public IP.
  2. Certbot validates domain ownership via HTTP‑01 or DNS‑01 challenges.
  3. The obtained certificate is placed in a shared volume.
  4. The reverse proxy reloads the certificate and begins serving HTTPS traffic. 5. A cron job or systemd timer triggers periodic renewal.

Historical context The practice of automating TLS for homelabs gained momentum around 2016 when Let’s Encrypt opened its beta program. Early adopters used standalone Certbot instances on the host OS, which often led to permission issues and complex path configurations. The introduction of Docker images for Certbot (official and community‑maintained) simplified the process, allowing the client to run inside a container that could share a volume with the web server.

Around 2020, projects like Nginx Proxy Manager emerged, offering a graphical UI for managing reverse proxy rules, SSL certificates, and access controls — all within Docker Compose. This shift reduced the need for manual Nginx configuration files and made it feasible for non‑engineers to deploy sophisticated networking stacks.

Key features and capabilities

  • Declarative configuration – Docker Compose files declare services, networks, and volumes in a single YAML file.
  • Volume sharing – Certbot writes certificates to a host‑mounted directory that the proxy can read.
  • Automatic renewal – Certbot’s built‑in renewal daemon can be triggered by a timer, eliminating manual intervention.
  • Container‑aware routing – Labels or environment variables can expose ports dynamically, enabling zero‑downtime updates.
  • Extensibility – Additional services (e.g., monitoring, backup) can be added as separate containers without disrupting the core flow. ### Pros and cons
AdvantagesDisadvantages
Scalability – Adding new services is a matter of editing the Compose file.Complex dependencies – A misconfigured network can cause cascading failures.
Isolation – Each service runs in its own environment, reducing host contamination.Volume permission issues – Certbot may lack read access to the shared directory.
Automation – Renewal scripts can be scheduled with systemd timers or cron.Rate limiting – Let’s Encrypt imposes a 5‑certificate‑per‑week limit per domain.
Community support – Numerous Docker images and documentation are publicly available.Debugging difficulty – Logs are spread across multiple containers, making root‑cause analysis harder.

Use cases and scenarios

  • Personal homelab – Hosting multiple subdomains (e.g., blog.example.com, cloud.example.com) with individual TLS certificates.
  • Self‑hosted SaaS – Providing internal web applications (e.g., GitLab, Nextcloud) over HTTPS without exposing private keys to the host OS. - Edge caching – Using a reverse proxy to terminate TLS and forward requests to internal services, reducing the attack surface.
  • CI/CD pipelines – Leveraging the same Compose stack for testing TLS configurations before production rollout.
  • Container‑native DNS challenges – Projects like acme.sh support DNS‑01 via API tokens, enabling renewal without exposing HTTP ports.
  • Zero‑trust networking – Integration with tools like Caddy that automatically obtain certificates based on hostnames without additional configuration.
  • Immutable infrastructure – Deploying the entire stack as a version‑controlled Compose file, allowing quick rollbacks when a renewal triggers a service outage.

Comparison to alternatives

ToolPrimary StrengthTypical Use Case
Certbot (standalone)Simple, widely documentedSmall labs with direct port exposure
acme.shLightweight, supports DNS‑01 out‑of‑the‑boxEnvironments where HTTP is blocked
CaddyAutomatic HTTPS, minimal configUsers who want “just works” TLS
TraefikDynamic routing, built‑in Let’s EncryptLarger deployments with frequent service changes
Nginx Proxy ManagerUI‑driven, easy for beginnersHomelab enthusiasts seeking visual control

Each option trades off simplicity for flexibility. The choice often depends on the operator’s comfort with YAML, desire for a graphical interface, and tolerance for debugging complex networking topologies. —

PREREQUISITES

Before you begin, verify that your environment meets the following baseline requirements.

Hardware and OS

  • A 64‑bit Linux distribution (Ubuntu 22.04 LTS, Debian 12, or CentOS 9) with at least 4 CPU cores, 8 GB RAM, and 100 GB of free storage.
  • Kernel version 5.4 or newer to support the latest Docker features.

Software dependencies

ComponentMinimum versionInstallation command
Docker Engine24.0.0curl -fsSL https://get.docker.com | sh && sudo systemctl start docker
Docker Compose (v2 plugin)2.24.0docker compose version (ensure it reports the plugin version)
Git2.40.0sudo apt-get install -y git
curl8.5.0Usually bundled with Docker install
jq1.6.0sudo apt-get install -y jq

Network and security considerations

  • Port exposure – Ensure that ports 80 (HTTP) and 443 (HTTPS) are reachable from the internet, unless you are using a VPN or reverse SSH tunnel.
  • Firewall – Configure ufw or firewalld to allow inbound traffic on 80/443 while blocking all other inbound ports. Example: sudo ufw allow 80/tcp && sudo ufw allow 443/tcp.
  • Dynamic DNS – If your public IP is not static, set up a DDNS service (e.g., DuckDNS) and update the DNS record before proceeding.

User permissions

  • Add your non‑root user to the docker group to avoid sudo for every Docker command: sudo usermod -aG docker $USER && newgrp docker.
  • Verify group membership: groups should list docker.

Pre‑installation checklist

  1. Verify Docker daemon is running: systemctl status docker.
  2. Confirm Compose plugin is loaded: docker compose version.
  3. Create a dedicated directory for the stack: mkdir -p ~/homelab/ssl‑automation && cd ~/homelab/ssl‑automation.
  4. Ensure the directory is writable by the docker group: chmod 775 . and chown $USER:$docker. —

INSTALLATION & SETUP

The following sections walk through a complete, production‑grade deployment of an automated TLS workflow using Docker Compose, Certbot, and Nginx Proxy Manager. All commands are annotated with explanations and safety checks.

1. Directory layout

1
2
3
4
5
# Create the project root
mkdir -p $HOME/homelab/ssl-automation
cd $HOME/homelab/ssl-automation# Subdirectories for each component
mkdir -p certbot/{conf,workdir}
mkdir -p nginx-proxy-manager/{data,ssl}

2. Docker Compose file

Create a file named docker-compose.yml with the following content. Replace placeholder values (example.com, your_email@example.com) with your actual domain and contact email.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
version: "3.9"

services:
  # Reverse proxy that will terminate TLS  nginx-proxy-manager:
    image: jc21/nginx-proxy-manager:latest    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "81:81"   # Admin UI
    volumes:
      - ./nginx-proxy-manager/data:/data
      - ./nginx-proxy-manager/ssl:/etc/letsencrypt
      - ./nginx-proxy-manager/logs:/var/log/nginx
    environment:
      - DB_VOLUME=/data
    networks:
      - proxy

  # Certificate acquisition and renewal container
  certbot:
    image: certbot/certbot:latest
    restart: unless-stopped
    depends_on:
      - nginx-proxy-manager
    volumes:
      - ./certbot/conf:/etc/letsencrypt
      - ./certbot/workdir:/var/www/certbot
    entrypoint: "/bin/sh -c"
    command: >
      'while true; do
         certbot renew --quiet --deploy-hook "nginx -s reload";
         sleep 12h;
       done'
    networks:
      - proxy

networks:
  proxy:
    driver: bridge

Explanation of key sections

  • nginx-proxy-manager – Exposes ports 80 and 443 on the host, mounts persistent
This post is licensed under CC BY 4.0 by the author.