Zum Hauptinhalt springen
Intelligence View
⚡ tsecurity.de Intelligence

Stop hand-rolling nginx + certbot for your self-hosted HTTPS

If you've done any self-hosting - a homelab, internal services, a small team's own tooling - you've probably been through this ritual: A service is running,…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
CVE & Threat-Kontext · 5 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung

If you've done any self-hosting - a homelab, internal services, a small team's own tooling - you've probably been through this ritual:



A service is running, you want to put a domain and HTTPS in front of it. So you install nginx, write a reverse-proxy config, install certbot, request a Let's Encrypt cert, and wire up a cron job to renew it. Three months later, the day the cert expires, you discover the cron path was wrong, or certbot's webroot mode is fighting your nginx config, and the site is a wall of red.



The third time I went through this, I decided to replace the whole thing. The short version: for self-hosted HTTPS, Caddy + DNS-01 gets you to "set it once, never touch it again." Here's the part that's actually worth knowing.






1. What Caddy's automatic HTTPS actually saves you



Caddy's most underrated feature is that the entire ACME flow is built in. No separate certbot, no renewal cron. A whole Caddyfile can be this short:




app.example.com {
reverse_proxy localhost:8080
}






Three lines. On startup Caddy will, on its own:




  1. Request a cert for app.example.com from Let's Encrypt;

  2. Store it locally and renew it automatically before expiry;

  3. Redirect port 80 to 443 with sane modern TLS.



Compared to nginx + certbot, what you delete is: the cert-request script, the renewal cron, the redirect rules, the TLS tuning. nginx can do all of this - it just makes you assemble every piece by hand, while Caddy ships "the correct defaults" as factory settings.






2. The real killer: DNS-01 gives certs to internal services too



The above is HTTP-01 validation: Let's Encrypt calls back to your port 80 to confirm you own the domain. The problem - what if your service is on a private network? The public internet can't reach your port 80, so HTTP-01 is simply out. This is the most common wall in self-hosting: a NAS, an internal admin panel, a homelab box - you want HTTPS but you're stuck at validation.



The fix is DNS-01 validation: instead of checking a port, it checks whether you can edit the domain's DNS records. Caddy uses your DNS provider's API (Cloudflare, Alibaba DNS, DNSPod, etc.) to write a TXT record automatically and complete validation. No inbound port ever has to be exposed to the public internet.



Better still, DNS-01 supports wildcard certs (*.example.com). Get one wildcard cert and every internal subdomain - grafana.lab.example.com, nas.lab.example.com, pad.lab.example.com - is covered by a single cert; new services don't need a fresh request:




*.lab.example.com {
tls {
dns cloudflare {env.CF_API_TOKEN}
}
@grafana host grafana.lab.example.com
handle @grafana {
reverse_proxy localhost:3000
}
@nas host nas.lab.example.com
handle @nas {
reverse_proxy localhost:5000
}
}






Note the official Caddy binary does not ship DNS plugins - you have to rebuild Caddy with the plugin for your provider (xcaddy build --with github.com/caddy-dns/cloudflare). This is where a lot of people get stuck: the official image throws "provider not found" on DNS-01, and you need to xcaddy your own build or use an image that bundles the plugin.






3. The things that will bite you



Once it's running, a few things you only learn by stepping on them:






1. Wildcard cert scope



*.example.com only covers one level of subdomain, not a.b.example.com (two levels). For two levels you need a separate *.b.example.com. Plan your subdomain hierarchy with this in mind.






2. DNS API token scope



The DNS token you hand Caddy should be scoped to edit TXT records on that one zone only - don't take the lazy path and give it an account-wide token. That token is partial control of your domain; leaked, it can be used to sign certs for you.






3. Let's Encrypt rate limits



50 certs per registered domain per week. Normal use won't hit it, but if you script container rebuilds that re-request a cert every time, you can easily get throttled until next week. Always persist the cert directory (mount a volume) so it isn't re-requested on every restart.






4. Don't forget WebSocket / gRPC



Reverse-proxying plain HTTP is fine, but if you later put a WebSocket service behind it (lots of admin panels stream live logs over WS), make sure the proxy forwards the Upgrade header correctly. Caddy's reverse_proxy does this by default, but it's a classic faceplant if you're hand-writing nginx config.






4. And then I packaged this too



I understood all of it, but rebuilding a plugin-enabled Caddy, writing a Caddyfile, configuring a DNS token, and tracking which subdomain points to which backend - for every new machine and every new service - still got old. So I folded it, along with the CI builds, multi-host deploys, and container management from before, into my single-binary Go deploy tool, Pipewright:




  • A bundled self-built Caddy image (with the major DNS plugins), so DNS-01 works out of the box;

  • Bind a domain, set up a wildcard cert, configure path routing - all from a few clicks in the web panel, no hand-written Caddyfile;

  • A certificate overview panel: every domain's cert status and expiry at a glance, no more openssl s_client one at a time;

  • And the feature I personally wanted most: per-PR preview environments - every PR spins up its own environment on a dedicated subdomain, torn down automatically when it's merged or closed. The "every PR gets a preview link" Vercel experience, self-hosted.



It's basically the "Caddy auto-HTTPS + DNS-01 wildcard" from this post, productized to skip the hand-rolling. MIT-licensed, single binary, no runtime deps (frontend baked in with embed.FS, SQLite by default), aimed at individual developers and small teams.



Repo: https://github.com/huangchengsir/pipewright



But even if you never touch it, the core of this post stands: stop hand-rolling nginx + certbot for self-hosted HTTPS. Caddy + DNS-01 + a wildcard cert - configure once and forget it exists.



Issues and pushback welcome.

Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:
✏️ Information ergänzen
🛡️ Versioniert via CMS-Revisions-Engine (Freigabe-Queue für Gäste)

💬 Community-Diskussion & Kommentare

🌐 Zum Hauptchat

Starte die Diskussion im Social-Chat Broadcast Stream oder reiche oben über „Information ergänzen“ einen Fachbeitrag ein.

🔍 CTI & Forensik

Cyber Threat Intelligence & Forensik

ATT&CK-Navigator · IoC-Radar · Exploit-Belege
MITRE ATT&CK Matrix Navigator
1 belegte Technik
T1053TA0003 · Persistence
Scheduled Task/Job
Mitigation: M1026 Privileged Account Management
Quelle: Kontext-Klassifikation des Artikeltextes · Konfidenz 78%
Scheduled Tasks/Cron-Jobs auditieren, Autoruns-Baseline abgleichen, Sigma-Detection-Regeln nutzen.
Persistence
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
5 Knoten · 4 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Security Briefing Kostenlos · 1-Klick-Abmeldung

Intelligence Digest — kostenlos

Täglich die wichtigsten Security-News · jederzeit abbestellbar

Community Rating & Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War dieser Artikel hilfreich?
0
Jetzt Bewertung abgeben
Detail-Bewertung (optional)
Inhalt & Qualität
Quelle & Glaubwürdigkeit
Aktualität

Verwandte Story-Cluster & Quellen (Vektor-KI)

6 Cluster
19 Quellen
Bluetti Black Friday: Drei empfehlenswerte Powerstations günstiger
ifun.de vor 21 Min.
18 weitere Quellen
CNETvor 21 Std.I Test Air Fryers. Cuisinart’s Glass Model Is a Steal at $84 for Black Friday t3n.devor 1 Std.Black Friday: Diese 9 Fritzboxen, Repeater und Co. sind wirklich günstig Golem.devor 53 Min.Anzeige: Leises Rudergerät zum Black Friday günstig wie nie bei Amazon heise online Newsvor 42 Min.Black Friday: Bei Saugrobotern kräftig sparen – Topmodelle zum Tiefstpreis AppleInsider Newsvor 41 Min.Black Friday price war drops Apple's M6 MacBook Pro to $1,779 WinFuture Newsvor 1 Std.Black-Friday-Deal: Lymow One Plus, der Panzer unter den Mährobotern netzwelt.devor 2 Std.Xiaomi TV F Pro im Black-Friday-Check: Wie gut ist der Fernseher-Hit wirklich? netzwelt.devor 1 Std.Wer eine Nintendo Switch 2 sucht, sollte sich diese Black-Friday-Aktion bei congstar anschauen Computer Bildvor 1 Std.Black Friday: Die besten Girokonto-Deals PC-WELTvor 1 Std.Amazon Black Friday Woche am Dienstag: Die besten Technik-Deals im Überblick PC-WELTvor 1 Std.Fritzbox 7690 mit Wi-Fi 7 bei Amazon im Black-Friday-Angebot: Jetzt deutlich günstiger Latest from TechRadarvor 1 Std.Proton VPN Plus vs Surfshark One: which plan is the better Black Friday deal right now? Latest from TechRadarvor 1 Std.Black Friday Oura Ring deals: The best of the deals so far, picked by a wearable-tech expert CNETvor 6 JahrenOur Favorite Blenders of 2026 Are on Sale Ahead of Black Friday CNETvor 1 Std.Brighten Up Your Day by Saving 20% Off Flashlights With Olight’s Black Friday Sale CNETvor 1 Std.Live: Black Friday Deals Are Here. Shop Expert Picks Across Tech, Everyday Essentials and More at Up to 60% Off Golem.devor 1 Std.Anzeige: Logitech-Tastatur MX Keys S am Black Friday zum Sensationspreis auf Amazon PC-WELTvor 2 Std.Luminar zum Black Friday: KI-Bildbearbeitung für nur 79,20 Euro
17 Quellen
CVE-2026-133764 | Twig up to 3.31.0 Sandbox toString sandbox (EUVD-2026-133913)
VulDB Updates vor 51 Min.
16 weitere Quellen
VulDB Updatesvor 51 Min.CVE-2026-133763 | Symfony Twig up to 3.31.0 Sandbox toString sandbox (EUVD-2026-133912) VulDB Updatesvor 51 Min.CVE-2026-132270 | Significant-Gravitas AutoGPT up to 0.8.4 Autopilot authorization (EUVD-2026-133583) VulDB Updatesvor 51 Min.CVE-2026-136123 | Friendica up to 2026.05-1 ActivityPub compactProfile input validation (EUVD-2026-133909) VulDB Updatesvor 51 Min.CVE-2026-136124 | welovemedia ffmate up to 2.0.x wildcardReplacer argument injection (EUVD-2026-133908) VulDB Updatesvor 1 Std.CVE-2026-72522 | Libexpat up to 2.8.2 Unicode *_toUtf16 out-of-bounds (EUVD-2026-54990 / Nessus ID 385514) VulDB Updatesvor 1 Std.CVE-2026-133773 | Twig markdown-extra up to 3.31.0 HtmlConverter html_to_markdown options resource consumption (EUVD-2026-133922) VulDB Updatesvor 1 Std.CVE-2026-133772 | Twig up to 3.30.x Sandbox sandbox (EUVD-2026-133921) VulDB Updatesvor 1 Std.CVE-2026-133770 | Twig up to 3.31.0 Sandbox __construct sandbox (EUVD-2026-133919) VulDB Updatesvor 1 Std.CVE-2026-133769 | Symfony html-extra up to 3.31.0 Cva Cva::apply sandbox (EUVD-2026-133918) VulDB Updatesvor 1 Std.CVE-2026-133767 | Twig up to 3.31.0 Sandbox __toString sandbox (EUVD-2026-133916) VulDB Updatesvor 1 Std.CVE-2026-133766 | Twig up to 3.31.0 Sandbox toString sandbox (EUVD-2026-133915) VulDB Updatesvor 1 Std.CVE-2026-133765 | Symfony Twig up to 3.31.0 Sandbox sandbox (EUVD-2026-133914) VulDB Updatesvor 2 Std.CVE-2026-13137 | Hitachi Energy RTU500 CMU up to 13.9.1 User management/REST resolver/SPA-Bus buffer overflow (EUVD-2026-133827) VulDB Updatesvor 2 Std.CVE-2026-131717 | Liquid Web, StellarWP Event Tickets Plugin up to 5.31.1 on WordPress authorization (EUVD-2026-131354) VulDB Updatesvor 2 Std.CVE-2026-126605 | Proton Pass up to 1.21.0 Face ID App Lock improper authentication (EUVD-2026-133826) VulDB Updatesvor 2 Std.CVE-2026-103406 | Juniper Session Smart Conductor up to 7.0.4/7.1.6/7.2.2 AutomatedProvisioner os command injection (EUVD-2026-112215)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Stop hand-rolling nginx + certbot for your self-hosted HTTPS

Thematisch verwandte Begriffe: Stop, handrolling, nginx, certbot · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Widgets & Themen
Widgets werden geladen…
Nächster Beitrag