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)
Quelle & Fakten · 5 Min. Lesezeit
Quelle: dev.to
Rubrik: Programmazione sicura

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)

💬 Discussione della community e commenti

🌐 Entra nella chat principale

Avvia la discussione nel flusso broadcast della Social Chat oppure invia qui sopra un contributo esperto tramite il modulo di integrazione.

Briefing di sicurezza Gratuito · disdetta in 1 clic

Intelligence Digest — gratuito

Ogni giorno le notizie di sicurezza più importanti · annullabile in qualsiasi momento

Valutazione della community & prova sociale
⭐ Giudizio dei lettori
–
Ø / 5.0
Ancora nessuna valutazione dei lettori
Questo articolo ti è stato utile?
0
Lascia ora la tua valutazione
Valutazione dettagliata (facoltativa)
Contenuto & qualità
Fonte & credibilità
Attualità

Cluster di storie correlate & fonti (IA vettoriale)

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

Caricamento dei video ...

Laden...

Caricamento degli articoli ...

Laden...

Caricamento dei video ...

Laden...

Caricamento degli articoli ...

Laden...

Caricamento dei video ...

Laden...

Caricamento degli articoli ...

Laden...

Caricamento dei video ...

Laden...

Caricamento degli articoli ...

Laden...

Caricamento dei video ...

💬 Caricamento dei commenti…
Trascina per aggiornare
Widgets & Topics
Loading widgets…
Nächster Beitrag