docs/content/dns/_index.md
[!INFO] Important lego is an independent, free, and open-source project, if you value it, consider supporting it! ❤️
Credentials and DNS configuration for DNS providers must be passed through environment variables.
The environment variables can reference a value.
CLOUDFLARE_EMAIL='[email protected]' \
CLOUDFLARE_API_KEY='yourprivatecloudflareapikey' \
...
_FILE suffixThe environment variables can reference a path to a file.
In this case the name of environment variable must be suffixed by _FILE.
{{< tabs >}} {{% tab title="Command" %}}
CLOUDFLARE_EMAIL_FILE=/the/path/to/my/email \
CLOUDFLARE_API_KEY_FILE=/the/path/to/my/key \
lego run --dns cloudflare --domains www.example.com
{{% /tab %}} {{% tab title="/the/path/to/my/key" %}}
yourprivatecloudflareapikey
{{% /tab %}} {{% tab title="/the/path/to/my/email" %}}
{{% /tab %}} {{< /tabs >}}
{{% notice note %}} The file must contain only the value. {{% /notice %}}
You can also use a dotenv file.
When using lego run, you can pass the path to the dotenv file with the --env-file flag.
{{< tabs >}} {{% tab title="Command" %}}
lego run --dns cloudflare --domains 'example.org' --domains '*.example.org' --env-file .env.cf
{{% /tab %}} {{% tab title=".env.cf" %}}
CLOUDFLARE_EMAIL[email protected]
CLOUDFLARE_API_KEY=yourprivatecloudflareapikey
{{% /tab %}} {{< /tabs >}}
When using lego, the environment variables are loaded from the file defined by envFile in the configuration file for the DNS provider.
{{< tabs >}} {{% tab title=".lego.yml" %}}
challenges:
cf:
dns:
provider: cloudflare
envFile: .env.cf
certificates:
foo:
domains:
- example.com
- '*.example.com'
{{% /tab %}} {{% tab title=".env.cf" %}}
CLOUDFLARE_EMAIL[email protected]
CLOUDFLARE_API_KEY=yourprivatecloudflareapikey
{{% /tab %}} {{< /tabs >}}
{{% tableofdnsproviders %}}