Labelgate

DNS Labels

Create Cloudflare DNS records from container labels.

One label is enough. This creates a proxied A record for app.example.com that points to this host's public IP:

services:
  web:
    image: nginx:alpine
    labels:
      labelgate.dns.web.hostname: "app.example.com"

When the container is removed, the record is deleted 30 minutes later (sync.remove_delay).

Labels

Every label has the form labelgate.dns.<name>.<property>. The <name> is any name you choose; see The name part.

PropertyRequiredDefaultExampleMeaning
hostnameyes-app.example.comRecord name.
typenoACNAMEA, AAAA, CNAME, TXT, MX, SRV or CAA.
targetA/AAAA: no, others: yesauto203.0.113.10Record value. See Targets.
proxiednotruefalseOrange cloud. Only A, AAAA and CNAME can be proxied.
ttlnoauto300TTL in seconds, up to 86400. 0 or 1 means auto. Proxied records always use auto.
cleanupnotruefalseDelete the record when the container is gone. false keeps it.
credentialnoautocompanyWhich API token to use. default is cloudflare.api_token.
accessno-teamPut an Access policy in front of the hostname.
commentno-blogExtra text for the record's comment in Cloudflare.
priorityno010MX and SRV only. 0-65535.
weightno05SRV only. 0-65535.
portno05222SRV only. 0-65535.
flagsno0128CAA only. 0-255.
tagnoissueissuewildCAA only. issue, issuewild or iodef.

Targets

For A and AAAA records:

targetResult
auto (default)The host's public IP: IPv4 for A, IPv6 for AAAA. For a container on an agent, the agent host's public IP.
containerThe container's own IP address.
An IP addressThat address, e.g. 203.0.113.10 for A or 2001:db8::10 for AAAA.

For other types, target is required:

  • CNAME, MX, SRV: a hostname, e.g. mail.example.com.
  • TXT, CAA: the value, used as written.

If auto or container finds no address (for example, no public IPv6), the record shows an error and Labelgate retries on every sync.

Recipes

Fixed IP, DNS only (grey cloud)

labels:
  labelgate.dns.web.hostname: "app.example.com"
  labelgate.dns.web.target: "203.0.113.10"
  labelgate.dns.web.proxied: "false"

Several records from one container

labels:
  labelgate.dns.root.hostname: "example.com"
  labelgate.dns.www.hostname: "www.example.com"
  labelgate.dns.www.type: "CNAME"
  labelgate.dns.www.target: "example.com"

Mail: MX and SPF

labels:
  labelgate.dns.mx.hostname: "example.com"
  labelgate.dns.mx.type: "MX"
  labelgate.dns.mx.target: "mail.example.com"
  labelgate.dns.mx.priority: "10"
  labelgate.dns.spf.hostname: "example.com"
  labelgate.dns.spf.type: "TXT"
  labelgate.dns.spf.target: "v=spf1 mx ~all"

priority defaults to 0. Set it when it matters.

SRV

labels:
  labelgate.dns.xmpp.hostname: "_xmpp-client._tcp.example.com"
  labelgate.dns.xmpp.type: "SRV"
  labelgate.dns.xmpp.target: "xmpp.example.com"
  labelgate.dns.xmpp.priority: "10"
  labelgate.dns.xmpp.weight: "5"
  labelgate.dns.xmpp.port: "5222"

CAA

labels:
  labelgate.dns.caa.hostname: "example.com"
  labelgate.dns.caa.type: "CAA"
  labelgate.dns.caa.target: "letsencrypt.org"

Keep the record after the container is gone

labels:
  labelgate.dns.web.hostname: "app.example.com"
  labelgate.dns.web.cleanup: "false"

Per-container defaults

labelgate.dns.default.<property> sets a default for every DNS name in the same container. Allowed properties: type, target, proxied, ttl, credential, cleanup.

labels:
  labelgate.dns.default.proxied: "false"
  labelgate.dns.a.hostname: "a.example.com"
  labelgate.dns.b.hostname: "b.example.com"

Good to know

  • Labelgate only changes records it created. It marks them with labelgate:<id> at the start of the record comment; your comment text goes after it.
  • An existing record with the same name and type is never taken over. You get conflict: existing record not owned by labelgate. See Ownership & Conflicts.
  • Do not add a DNS label for a hostname that a tunnel label already uses. The tunnel creates its own record.

On this page