Bỏ qua để đến nội dung
Playbook: DNS, TLS and SSL Point a domain at a server through a connected DNS provider (dns_records_*), issue and renew Let's Encrypt certificates (ssl.issue, ssl_renew), wildcard DNS-01 and Cloudflare Origin certificates, custom certificates and CDN purges from an AI agent.

Playbook: DNS, TLS and SSL

Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.

Two layers are involved:

  • DNS at a provider. Records live at Cloudflare (the supported provider), handled through control-plane operations dns_*. No agent is needed.
  • Certificates on the box. Let’s Encrypt certificates are issued and renewed by the agent with ssl.* job kinds. Wildcard, Cloudflare Origin and custom certificates are handled through dns_* operations that then install the certificate on a server.

Cloudflare DNS, SSL and wildcard certificates are available on every plan.

Token: operate for record create and update. Deleting a record needs full + data:delete, and connecting a provider needs full + webhooks:admin.

  1. Find the server’s public IP: servers_ip_get {id} (use stored, or observed when there is no stored address).

  2. Check that the zone is connected: dns_connections_list lists connections and their zones (only the token’s last 4 characters are shown). If there’s none, the user connects Cloudflare at /connect/dns, or you call dns_connections_create {body: {provider: "cloudflare", token, account?}} (the token needs Zone.DNS edit).

  3. Look at the existing records: dns_records_list {query: {domain: "example.com"}}.

  4. Create the record:

    { "body": { "domain": "example.com", "type": "A", "name": "shop.example.com",
    "content": "203.0.113.10", "ttl": 1, "proxied": false } }

    This is dns_records_create. domain selects the zone, and ttl: 1 means automatic. To change a record, call dns_records_update {id: <provider record id>, body: {…same fields}}.

  5. Verify resolution from the box: jobs_create dns.lookup {domain: "shop.example.com"}.

Two-level names: Cloudflare’s free edge certificate covers only the apex and one label below it, so never proxy a name such as app.dev.example.com — keep it proxied: false and issue Let’s Encrypt on the box. The record MZPanel creates for a new site follows this rule.

Proxied (orange-cloud) records: if the zone runs Cloudflare in Full (strict) mode, a Cloudflare Origin certificate on the server is an alternative to Let’s Encrypt (see below).

Token: operate. HTTP-01 needs the record to resolve to the server and port 80 to be reachable.

  1. jobs_create {id, body: {type: "ssl.issue", domain: "shop.example.com"}}, then poll jobs_get.
  2. Verify: ssl_list {server} (core tool, live) or servers_inventory {id, kind: "ssl"} show the certificate and its expiry.
  3. Force HTTPS: ssl.https-redirect {domain, enabled: true}.

site.create with sslMode: "auto" (the default) already tries to issue a certificate when the site is created.

  • Preview, then renew: core ssl_renew {server, domain?} runs a dry run, and ssl_renew {…, apply: true} renews for real. Leave out domain to renew every certificate that is due.
  • Or as a job: ssl.renew {domain?, dryRun?}.
  • Per-domain auto-renew: ssl.auto-renew {domain, enabled}.
  • Remove a certificate: ssl.delete {domain}.

4. Wildcard, Origin and custom certificates

Section titled “4. Wildcard, Origin and custom certificates”

Token: full.

NeedOperationBody
Wildcard *.example.com (ACME DNS-01 through the connected zone)dns_wildcard_cert{serverId, domain}
List or stop tracking wildcardsdns_wildcard_certs_list · dns_wildcard_certs_delete {id} (data:delete)
Cloudflare Origin certificate installed on a serverdns_origin_certsee GET /v1/api/operations
Generate a CSR on a server (to buy a certificate)dns_csr (operate)
Install a custom or paid certificatedns_install_certsee GET /v1/api/operations

Wildcards need a managed (agent) server and a connected zone that covers the domain.

  • dns_edge_get {query: {domain}} tells you whether a connected zone fronts the domain.
  • dns_edge_purge {body: {domain, urls: [...]}} purges up to 500 URLs (operate).

Authoritative DNS on your own server (BIND9)

Section titled “Authoritative DNS on your own server (BIND9)”

If the user runs their own nameserver on a box (the bind9 extension), zones and records are job kinds: dns.zone-list, dns.zone-create {domain, ip}, dns.record-list, dns.record-add {domain, name, recordType, value, ttl?, priority?}, dns.record-del, dns.ns-get / dns.ns-set {ns, rname?} and dns.reload. Deleting a whole zone (dns.zone-delete) needs data:delete.

  • ssl.issue failed: the record doesn’t resolve to this server yet (check dns.lookup), port 80 is blocked, or Let’s Encrypt rate-limited repeated attempts. Wait before retrying.
  • dns_records_create returns not_found or 400: no connected zone covers domain, or the provider token lacks DNS edit permission. dns_connections_verify {id} re-checks it.
  • wildcard_failed (502): the DNS-01 challenge failed at the provider. Read the message.