configure-dns-tls
Skill9 starsChanged 5 months agoApache-2.0View on GitHub
Configures DNS records and TLS for a service — A/AAAA/CNAME/ALIAS/MX/TXT/CAA, zero-downtime cutovers via pre-lowered TTL, automated ACME/Let's Encrypt/cert-manager issuance and auto-renewal, and TLS 1.2+/1.3-only settings with HSTS, OCSP stapling, and 80→443 redirect — eliminating expired-cert and bad-cutover outages.
In this repository147 other files it gives its agents.
- second-brain/AGENTS.mdAGENTS.md
- second-brain/CLAUDE.mdCLAUDE.md
- agent-tool-mcp-builderSkill
- api-design-reviewSkill
- async-concurrency-correctnessSkill
- audit-accessibility-wcagSkill
- audit-license-complianceSkill
- audit-technical-seoSkill
- auth-jwt-sessionSkill
- author-codemodSkill
- brainstorm-designSkill
- build-audit-loggingSkill
- build-cdc-streaming-pipelineSkill
- build-cli-toolSkill
- build-data-tableSkill
- build-etl-pipelineSkill
- build-form-validationSkill
- build-native-mobile-uiSkill
- build-office-docsSkill
- build-offline-first-syncSkill
- build-react-componentSkill
- build-realtime-channelSkill
- build-spreadsheetSkill
- build-vector-searchSkill
- caching-strategySkill
- cicd-pipeline-authorSkill
- cloud-cost-optimizeSkill
- code-commentsSkill
- code-reviewSkill
- compose-local-dev-stackSkill
- configure-bundler-buildSkill
- configure-reverse-proxy-lbSkill
- configure-security-headers-cspSkill
- contract-testingSkill
- datetime-timezone-correctnessSkill
- db-migration-safetySkill
- debug-ci-pipeline-failureSkill
- debug-flaky-testsSkill
- debug-frontend-browserSkill
- debug-root-causeSkill
- defend-llm-prompt-injectionSkill
- deliver-webhooksSkill
- dependency-upgradeSkill
- deploy-releaseSkill
- design-api-paginationSkill
- design-authorization-modelSkill
- design-backup-dr-recoverySkill
- design-event-sourcing-cqrsSkill
- design-multi-tenancySkill
- design-protobuf-grpc-serviceSkill
- design-relational-schemaSkill
- design-search-index-infraSkill
- design-state-machineSkill
- design-token-systemSkill
- diff-table-paritySkill
- distributed-locks-leasesSkill
- dockerfile-optimizeSkill
- encrypt-sensitive-dataSkill
- error-messageSkill
- estimate-workSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 49
Run both origins in parallel (old + new healthy) during the switch — never tear down old first.
- Distinctive: line 51
Verify the new answer is served (step in Verify) and the new origin takes real traffic.
- Distinctive: line 52
Only after traffic has fully drained from the old origin (watch its access logs go quiet for > one TTL), decommission it and raise TTL back …
- Distinctive: line 92
Default: SAN cert via DNS-01 for anything non-trivial.
- Distinctive: line 121
Raising TTL or killing the old origin too early: Do it only after old-origin logs go quiet for > one TTL.
- Very specific: line 122
Missing/forbidding CAA: No CAA = any CA may issue (security gap).
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
Reach for this skill when the task is names and certificates — getting a domain to resolve to your service and serving valid HTTPS that renews itself:
- "Point
app.example.comat this load balancer / IP without downtime" - "Enable HTTPS / fix the expired-cert outage / stop the cert from ever expiring again"
- "Automate certs with Let's Encrypt / cert-manager; issue a wildcard"
- "Migrate DNS to a new provider / cut over to a new origin"
- "Lock down SPF/DKIM/DMARC, or CAA so only my CA can issue"
- "Why does SSL Labs give us a B? Harden the TLS config"
NOT this skill:
- Configuring the proxy/LB/Ingress that terminates TLS, virtual hosts, upstream pools, timeouts → configure-reverse-proxy-lb
- The CDN/edge, WAF rules, edge caching, or DDoS layer in front of origin → setup-cdn-edge-waf
- Application-layer auth/authz, token scopes, RBAC → design-authorization-model
- Tamper-evident security event logs (incl. cert-rotation events) → build-audit-logging
This skill owns the record values, the cutover choreography, certificate lifecycle, and the TLS handshake policy. It hands the terminated connection to the proxy.
Steps
Pick the record type by what you're pointing at — do not CNAME the apex.
Need Record Notes Name → IPv4 ABare IP only Name → IPv6 AAAAAdd alongside A; serve dual-stack Subdomain → another hostname CNAMEe.g. www → app.example.com; cannot coexist with other records on that nameApex ( example.com) → hostnameALIAS/ANAME/flattened-CNAMEApex can't be a real CNAME (breaks SOA/NS/MX). Use the provider's ALIAS (Route 53 alias, Cloudflare CNAME-flattening, etc.) Mail MXPriority + target; target must be an A/AAAA, never a CNAME SPF/DKIM/DMARC/verification TXTOne SPF per domain; DMARC at _dmarc; DKIM at<sel>._domainkeyWho may issue certs CAA0 issue "letsencrypt.org"+0 issuewild "letsencrypt.org"Set CAA before first ACME issuance, or issuance fails with
CAA record prevents issuance. Example:example.com. CAA 0 issue "letsencrypt.org" example.com. CAA 0 issuewild "letsencrypt.org" example.com. CAA 0 iodef "mailto:security@example.com"- Zero-downtime cutover: lower the TTL BEFORE the change — this is the whole trick. Resolvers cache the old answer for up to its TTL; if you cut over while TTL is 3600, clients hit the dead origin for an hour.
- Drop the record's TTL to
60(or30). Wait out the old TTL (e.g. wait the full prior 3600s) so every cache holds the short TTL. - Run both origins in parallel (old + new healthy) during the switch — never tear down old first.
- Change the record value to the new target.
- Verify the new answer is served (step in Verify) and the new origin takes real traffic.
- Only after traffic has fully drained from the old origin (watch its access logs go quiet for > one TTL), decommission it and raise TTL back to 3600+ to cut query volume/cost.
- Drop the record's TTL to
Automate certificates — manual renewal is a guaranteed future outage. Use ACME (Let's Encrypt / ZeroSSL). Never click-issue a 1-year cert you have to remember to renew; LE is 90-day by design to force automation.
- VM / bare proxy:
certbotwith a renewal timer, or the proxy's built-in ACME (Caddy auto-HTTPS, Traefik resolver, nginx +acme.sh). - Kubernetes: cert-manager — a
ClusterIssuer+Certificate(or Ingress annotation) reconciles renewal automatically; renews at ~⅔ of lifetime.
# cert-manager: DNS-01 wildcard via Cloudflare apiVersion: cert-manager.io/v1 kind: ClusterIssuer metadata: { name: letsencrypt-prod } spec: acme: server: https://acme-v02.api.letsencrypt.org/directory email: ops@example.com privateKeySecretRef: { name: letsencrypt-prod-key } solvers: - dns01: cloudflare: apiTokenSecretRef: { name: cloudflare-token, key: api-token } --- apiVersion: cert-manager.io/v1 kind: Certificate metadata: { name: example-tls, namespace: web } spec: secretName: example-tls # Ingress references this issuerRef: { name: letsencrypt-prod, kind: ClusterIssuer } dnsNames: ["example.com", "*.example.com"]Iterate against the staging ACME server first — set the
ClusterIssuerspec.acme.servertohttps://acme-staging-v02.api.letsencrypt.org/directory(orcertbot --test-cert) to dodge LE prod rate limits (50 certs / registered-domain / week) while debugging, then flip the server back to prod and re-issue.- VM / bare proxy:
Choose the ACME challenge and cert shape deliberately.
Axis Pick Why HTTP-01 single host, port 80 reachable from internet simplest; needs /.well-known/acme-challenge/served; cannot do wildcardsDNS-01 wildcards, internal hosts, no inbound 80, or many SANs proves control via a _acme-challengeTXT; needs DNS-provider API creds; works behind a firewallWildcard *.example.commany dynamic subdomains DNS-01 only; one cert, but a single shared private key (bigger blast radius) SAN / multi-domain a known fixed set of names explicit per-name; rotate one without touching others; preferred when the list is stable Default: SAN cert via DNS-01 for anything non-trivial; wildcard only when subdomains are unbounded/dynamic.
Set a modern TLS policy at the terminator — TLS 1.2+ only, redirect, HSTS, stapling. Configure on whatever terminates (see configure-reverse-proxy-lb), but the policy is owned here:
- Protocols: TLS 1.3 + TLS 1.2 only. Disable TLS 1.0/1.1 and SSLv3 entirely.
- Ciphers: TLS 1.3 defaults; for 1.2 use forward-secret AEAD suites (ECDHE + AES-GCM/CHACHA20), no CBC/RC4/3DES.
- Redirect 80→443 with
301, then serve everything over HTTPS. - HSTS on HTTPS responses:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload— but only addpreload/includeSubDomainsonce every subdomain is HTTPS (it's hard to undo). Roll out short → long → preload. - OCSP stapling on (
ssl_stapling on;in nginx) so clients don't round-trip the CA. - Serve the full chain (leaf + intermediates), not just the leaf — the #2 cause of "works in my browser, fails in
curl/old Android".
server { listen 443 ssl http2; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers off; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # full chain ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_stapling on; ssl_stapling_verify on; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always; } server { listen 80; server_name example.com; return 301 https://$host$request_uri; }- Prove auto-renew works before you trust it. A cert that issues fine but never renews is a 90-day time bomb. Force a dry-run/staging renewal now (step in Verify) so you discover broken DNS creds or a missing port today, not at 2am on day 89.
Common Errors
- CNAME on the apex. Breaks NS/SOA/MX co-existence; many resolvers reject it. Use ALIAS/ANAME/CNAME-flattening for
example.com. - Cutover without pre-lowering TTL. You switch the record but caches serve the dead origin for the full old TTL (often an hour). Lower TTL and wait out the old TTL first.
- Raising TTL or killing the old origin too early. Do it only after old-origin logs go quiet for > one TTL; otherwise stragglers 502.
- Missing/forbidding CAA. No CAA = any CA may issue (security gap); a CAA that omits your CA = ACME fails with
CAA record prevents issuance. Add the issuing CA explicitly, includingissuewildfor wildcards. - HTTP-01 for a wildcard. Impossible — wildcards require DNS-01. Switch the solver.
- Manual cert renewal "we'll remember." You won't. The outage is scheduled for expiry day. Automate or it will lapse.
- Serving only the leaf cert. Browsers cache intermediates and "work";
curl, Java, old Android, and API clients fail chain validation. Always deployfullchain.pem. - Burning LE rate limits while debugging. Iterate against
acme-staging-v02(orcertbot --test-cert); only hit prod once issuance succeeds in staging. includeSubDomains/preloadHSTS before all subdomains are HTTPS. Any plain-HTTP subdomain becomes unreachable, andpreloadis baked into browsers for months. Roll HSTS out short → long → preload.- DNS-01 with under-scoped API creds. The token can't write
_acme-challengeTXT, so renewal silently fails. Scope the token to DNS-edit on that zone and test it. - Mixed content after enabling HTTPS. Page loads over HTTPS but pulls
http://assets → browser blocks them. Rewrite asset URLs tohttps://or protocol-relative; verify console is clean. - Clock skew on the TLS host. A wrong system clock makes a valid cert read as not-yet-valid/expired. Run NTP.
Verify
- Records resolve correctly:
dig +short A app.example.com(andAAAA) returns the new target;dig CAA example.comshows your CA;dig TXT _dmarc.example.comshows the DMARC policy. Query an external resolver (dig @1.1.1.1 …) too, not just the local cache. - TTL was actually lowered before cutover:
dig app.example.com | grep -E '^app'shows the short TTL before you change the value; confirm the answer flips after, and that it propagated (dig @8.8.8.8and@1.1.1.1agree). - Full chain + protocol scan:
echo | openssl s_client -connect example.com:443 -servername example.com -showcertsshows leaf and intermediate(s),Verify return code: 0 (ok).testssl.sh example.com(or SSL Labs) reports TLS 1.2/1.3 only, no TLS 1.0/1.1, HSTS present, OCSP stapled — target grade A/A+. - Redirect + HSTS:
curl -sI http://example.com→301tohttps://;curl -sI https://example.com | grep -i strict-transportshows the HSTS header. - No mixed content: load the page, browser console shows zero "Mixed Content" / blocked-asset warnings; all subresources are
https://. - Expiry & auto-renew proven:
echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -enddateshows a future date; then force a staging renewal —certbot renew --dry-run(VM) or, for k8s, point the issuer atacme-staging-v02, runcmctl renew example-tls, and watchcmctl status certificate example-tlsgo Ready — and confirm a fresh cert issues without manual steps. - Mail auth (if MX set): SPF/DKIM/DMARC TXT records validate (e.g. an external mail-tester) — no
softfail/missing-DKIM.
Done = every name resolves to the new target on external resolvers, HTTPS serves the full chain over TLS 1.2/1.3 only with HSTS + stapling + 80→443 redirect and no mixed content (SSL Labs/testssl ≥ A), CAA locks issuance to your CA, and a staging force-renew has proven auto-renewal works before any cert nears expiry.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

