惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Heimdal Security Blog
SecWiki News
SecWiki News
H
Hacker News: Front Page
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
AI
AI
C
Cybersecurity and Infrastructure Security Agency CISA
Scott Helme
Scott Helme
PCI Perspectives
PCI Perspectives
S
Securelist
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cyberwarzone
Cyberwarzone
A
Arctic Wolf
Forbes - Security
Forbes - Security
T
Tor Project blog
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
I
Intezer
Martin Fowler
Martin Fowler
Help Net Security
Help Net Security
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
博客园 - 司徒正美
W
WeLiveSecurity
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
P
Palo Alto Networks Blog
Google DeepMind News
Google DeepMind News
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
V
Vulnerabilities – Threatpost
Jina AI
Jina AI
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
Simon Willison's Weblog
Simon Willison's Weblog
Project Zero
Project Zero
T
Threatpost
P
Privacy International News Feed
人人都是产品经理
人人都是产品经理
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Guide to Automatic SSL Certificate Renewal for Nginx and Docker
Mustafa ERBA · 2026-05-11 · via DEV Community

Mustafa ERBAY

Not long ago, when the certificate for the hesapciyiz.com site I host on my own VPS expired, I woke up to an email in the middle of the night. Yes, Let's Encrypt's certificate had expired, and I had forgotten to renew it. This situation highlighted how tiring and error-prone manual certificate management can be.

ℹ️ The Problem with Manual Renewals

Manual certificate renewal is a common pitfall for many. You might forget, or the process itself can be complex, especially when dealing with multiple domains or services. This is where automation becomes not just a convenience, but a necessity.

This incident was the catalyst for me to implement an automated SSL certificate renewal system for my Nginx and Docker setup. In this guide, I'll walk you through the exact steps I took, the commands I used, and the challenges I overcame.

Why Automate?

Before diving into the technical details, let's quickly touch upon why automation is crucial here:

  • Reliability: Automated systems don't forget. They run on a schedule, ensuring your certificates are always up-to-date.
  • Security: Expired certificates can lead to security warnings for your users and can even make your site inaccessible. Automation prevents this.
  • Time-Saving: Manually renewing certificates is a repetitive task that can be automated, freeing up your time for more important work.
  • Reduced Errors: Manual processes are prone to human error. Automation minimizes these risks.

My Setup: Nginx, Docker, and Let's Encrypt

My current setup involves:

  • Nginx: Acting as a reverse proxy for my applications.
  • Docker: Containerizing my applications and services.
  • Let's Encrypt: The free, automated, and open certificate authority.
  • Certbot: The tool that automates the process of obtaining and renewing Let's Encrypt certificates.

The goal is to have Certbot automatically renew certificates for domains served by Nginx, all managed within Docker.

Step-by-Step Implementation

Here's how I set up the automatic renewal:

1. Installing Certbot and Nginx

If you don't already have Nginx and Certbot installed, you'll need to do that first. For Debian/Ubuntu systems, this typically looks like:

sudo apt update
sudo apt install nginx certbot python3-certbot-nginx -y

Enter fullscreen mode Exit fullscreen mode

If you're using Docker for Nginx, you'll manage the Nginx container via docker-compose.

2. Initial Certificate Acquisition

Before automating renewal, you need to obtain your first certificate. Certbot can do this for you.

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Enter fullscreen mode Exit fullscreen mode

Replace yourdomain.com and www.yourdomain.com with your actual domain names. Certbot will guide you through the process, asking for your email address and agreeing to the terms of service. It will also ask if you want to redirect HTTP traffic to HTTPS, which is highly recommended.

3. Dockerizing Certbot and Nginx

To manage this within Docker, I created a docker-compose.yml file. Here's a simplified version of what that might look like:

version: '3.8'

services:
  nginx:
    image: nginx:latest
    container_name: nginx_proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./certbot/conf:/etc/letsencrypt
      - ./certbot/www:/var/www/certbot # For Certbot challenges
    depends_on:
      - app # Your application service

  certbot:
    image: certbot/certbot
    container_name: certbot
    volumes:
      - ./certbot/conf:/etc/letsencrypt
      - ./certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew --webroot -w /var/www/certbot --post-hook 'nginx -s reload'; sleep 12h & wait $${!}; done;'"
    # The entrypoint above is a simplified example. A more robust solution might use a cron job within the container or a separate cron job on the host.

  app: # Example of your application service
    image: your_app_image
    container_name: your_app
    # ... other configurations

Enter fullscreen mode Exit fullscreen mode

Explanation of Key Parts:

  • Volumes:
    • ./nginx/conf.d:/etc/nginx/conf.d: Mounts your Nginx configuration files.
    • ./certbot/conf:/etc/letsencrypt: This is crucial. It maps the directory where Certbot stores its certificates and configuration.
    • ./certbot/www:/var/www/certbot: This directory is used by Certbot's webroot authenticator to place the challenge files. Nginx needs to be configured to serve these files.
  • Certbot entrypoint:
    • This is a simplified example of how to run Certbot within its container. The while :; do ... sleep 12h & wait $${!}; done; loop attempts to run renewal every 12 hours.
    • certbot renew --webroot -w /var/www/certbot: This command tells Certbot to renew existing certificates using the webroot method. The -w flag specifies the webroot directory where Certbot should place the challenge files.
    • --post-hook 'nginx -s reload': This is vital. After a successful renewal, it tells Certbot to send a reload signal to Nginx. This makes Nginx pick up the new certificate without restarting the entire service, preventing downtime.

4. Nginx Configuration for Certbot Challenges

Your Nginx configuration needs to be set up to serve the challenge files from the directory mounted by Certbot. In your nginx/conf.d/default.conf (or similar), you'll need a location block like this:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        proxy_pass http://app:3000; # Or your application's address
        # ... other proxy settings
    }
}

Enter fullscreen mode Exit fullscreen mode

This tells Nginx to serve any requests for /.well-known/acme-challenge/ from the /var/www/certbot directory, which is where Certbot places its verification files.

5. Automating Renewal with Cron (More Robust Approach)

While the entrypoint in the docker-compose.yml can work, a more robust and common approach is to use cron on your host machine to trigger the Certbot renewal process.

First, ensure your docker-compose.yml has the Certbot service defined but perhaps without the complex entrypoint loop, or with a simpler one that just runs certbot renew once.

Then, on your host machine, edit your crontab:

sudo crontab -e

Enter fullscreen mode Exit fullscreen mode

Add a line like this to run the renewal twice a day (e.g., at 3:00 AM and 3:00 PM):

0 3,15 * * * docker-compose -f /path/to/your/docker-compose.yml run --rm certbot renew --webroot -w /var/www/certbot --post-hook 'docker-compose -f /path/to/your/docker-compose.yml exec nginx nginx -s reload'

Enter fullscreen mode Exit fullscreen mode

Explanation:

  • 0 3,15 * * *: This cron schedule runs the command at 3:00 AM and 3:00 PM every day.
  • docker-compose -f /path/to/your/docker-compose.yml run --rm certbot: This command runs the certbot service defined in your docker-compose.yml file. The --rm flag ensures the container is removed after it exits.
  • renew --webroot -w /var/www/certbot: Same as before, telling Certbot to renew using the webroot method.
  • --post-hook 'docker-compose -f /path/to/your/docker-compose.yml exec nginx nginx -s reload': This is the crucial part for the cron job. It executes a command within the running Nginx container to reload Nginx.

⚠️ Cron Path Issues

Make sure your cron job has access to the docker-compose command and that the paths to your docker-compose.yml file are correct. You might need to specify the full path to docker-compose if it's not in the default PATH for cron.

Troubleshooting Common Issues

1. Certbot Cannot Reach /.well-known/acme-challenge/

This is the most common problem. It usually means Nginx isn't correctly serving the challenge files from the shared volume.

  • Check Volume Mappings: Ensure the certbot/www volume is correctly mapped in both your Nginx and Certbot services in docker-compose.yml.
  • Verify Nginx Config: Double-check that the location /.well-known/acme-challenge/ block is present and correctly points to the root directory that is shared with Certbot.
  • Permissions: Ensure the Nginx user inside the container has read permissions for the files in /var/www/certbot.

2. Nginx Not Reloading After Renewal

If certificates are renewed but your site still shows an old certificate or a security warning, the --post-hook command is likely failing.

  • Test the Hook Manually: Try running the renewal command with the --dry-run flag and then manually execute the nginx -s reload command (or the docker-compose exec equivalent) to see if it works.
  • Check Docker Logs: Examine the logs for both the Certbot container and the Nginx container for any error messages.

3. Rate Limits

Let's Encrypt has rate limits. If you're testing too frequently or have many failed attempts, you might get temporarily blocked. The --dry-run flag is your best friend here.

Testing the Automation

You don't need to wait for your certificate to expire to test your automation. Certbot provides a --dry-run option:

sudo certbot renew --dry-run

Enter fullscreen mode Exit fullscreen mode

This command simulates the renewal process without actually issuing or revoking certificates. It will tell you if the renewal would have been successful and if the post-hook command executed correctly.

💡 The Power of Dry Runs

Always use --dry-run after making changes to your configuration or setup. It's the safest way to ensure your automation works before it needs to.

Conclusion

Setting up automatic SSL certificate renewal for Nginx and Docker might seem daunting at first, but with the right configuration and understanding of how Certbot, Nginx, and Docker interact, it becomes a straightforward process. By following these steps and using tools like cron and --dry-run, you can ensure your sites remain secure and accessible without the headache of manual renewals.

This pragmatic approach has saved me countless hours and prevented those dreaded "certificate expired" emails. I hope this guide helps you achieve the same!