cloudns

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ClouDNS Module for Caddy

This package provides a DNS provider module for Caddy. It allows you to manage DNS records with ClouDNS for automated TLS certificate issuance via the ACME DNS challenge.

Caddy Module Name

dns.providers.cloudns

Installation

To use this module, build Caddy with it included. The simplest way is to use xcaddy:

xcaddy build --with github.com/caddy-dns/cloudns

Configuration

Credentials

The module authenticates with the ClouDNS HTTP API using an API user or API sub-user (created in the ClouDNS control panel under API & Resellers):

  • auth_id — ClouDNS API user ID (required if sub_auth_id is not provided)
  • sub_auth_id — ClouDNS API sub-user ID (required if auth_id is not provided)
  • auth_password — ClouDNS API password (required)

Each credential is resolved in this order:

  1. The value set in the Caddy configuration (JSON or Caddyfile), after placeholder resolution, so {env.CLOUDNS_AUTH_ID}-style values work.
  2. If unset, the corresponding environment variable is used as a fallback: CLOUDNS_AUTH_ID, CLOUDNS_SUB_AUTH_ID, CLOUDNS_AUTH_PASSWORD.

If no usable credentials are found by either path, provisioning fails with an error that names the missing setting.

Note: ClouDNS lets you restrict an API user by allowed IP addresses and zones; make sure the API user you configure is allowed to manage the zones Caddy serves, from the host Caddy runs on.

Retry behavior (optional)

All DNS operations retry transient API failures with exponential backoff. The defaults (5 attempts, 1s initial backoff, 30s max backoff) work well; they can be tuned if needed:

  • operation_retries — maximum attempts per API call
  • initial_backoff — delay before the first retry (doubles each attempt)
  • max_backoff — upper bound for the retry delay

Configuration Examples

Caddyfile, credentials from environment variables

With CLOUDNS_AUTH_ID (or CLOUDNS_SUB_AUTH_ID) and CLOUDNS_AUTH_PASSWORD set in Caddy's environment, no block is needed at all:

example.com {
  tls {
    dns cloudns
  }
}
Caddyfile, global configuration
{
  acme_dns cloudns {
    auth_id "<auth_id>"
    auth_password "<auth_password>"
  }
}
Caddyfile, per-site configuration
example.com {
  tls {
    dns cloudns {
      sub_auth_id "<sub_auth_id>"
      auth_password "<auth_password>"
      operation_retries 5
      initial_backoff 1s
      max_backoff 30s
    }
  }
}
JSON configuration

Placeholders are resolved when the provider is provisioned, so secrets can be kept out of the config file:

{
  "apps": {
    "tls": {
      "automation": {
        "policies": [
          {
            "issuers": [
              {
                "module": "acme",
                "challenges": {
                  "dns": {
                    "provider": {
                      "name": "cloudns",
                      "auth_id": "{env.CLOUDNS_AUTH_ID}",
                      "auth_password": "{env.CLOUDNS_AUTH_PASSWORD}"
                    }
                  }
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Environment Variables

The following environment variables are used as fallbacks for any credential not specified in the Caddy configuration:

  • CLOUDNS_AUTH_ID — ClouDNS API user ID
  • CLOUDNS_SUB_AUTH_ID — ClouDNS API sub-user ID
  • CLOUDNS_AUTH_PASSWORD — ClouDNS API password

Testing

go test ./...

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements

This module is based on the libdns/cloudns package and the Caddy project.

Documentation

Overview

Package cloudns adapts the libdns ClouDNS provider as a Caddy DNS provider module, for solving ACME DNS-01 challenges (and managing DNS records generally) with zones hosted at ClouDNS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	*cloudns.Provider
}

Provider wraps the provider implementation as a Caddy module.

func (Provider) CaddyModule

func (Provider) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Provider) Provision

func (p *Provider) Provision(ctx caddy.Context) error

Provision prepares the module for use. It resolves placeholders (such as {env.CLOUDNS_AUTH_ID}) in the credentials, falls back to the CLOUDNS_AUTH_ID, CLOUDNS_SUB_AUTH_ID, and CLOUDNS_AUTH_PASSWORD environment variables for values not present in the configuration, and then validates that a usable credential set is available. Implements caddy.Provisioner.

func (*Provider) UnmarshalCaddyfile

func (p *Provider) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the DNS provider from Caddyfile tokens. Syntax:

cloudns {
    auth_id "<auth_id>"
    sub_auth_id "<sub_auth_id>"
    auth_password "<auth_password>"
    operation_retries <count>
    initial_backoff <duration>
    max_backoff <duration>
}

All directives are optional: credentials not present in the Caddyfile fall back to the CLOUDNS_* environment variables at provision time, and the retry settings have built-in defaults.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址