2019-03-08 20:47:06 +02:00
|
|
|
---
|
|
|
|
title: "Cloudflare"
|
|
|
|
date: 2019-03-03T16:39:46+01:00
|
|
|
|
draft: false
|
|
|
|
slug: cloudflare
|
2022-06-17 00:25:42 +02:00
|
|
|
dnsprovider:
|
|
|
|
since: "v0.3.0"
|
|
|
|
code: "cloudflare"
|
|
|
|
url: "https://www.cloudflare.com/dns/"
|
2019-03-08 20:47:06 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|
|
|
|
<!-- providers/dns/cloudflare/cloudflare.toml -->
|
|
|
|
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|
|
|
|
|
|
|
|
|
|
|
|
Configuration for [Cloudflare](https://www.cloudflare.com/dns/).
|
|
|
|
|
|
|
|
|
|
|
|
<!--more-->
|
|
|
|
|
|
|
|
- Code: `cloudflare`
|
2022-06-17 00:25:42 +02:00
|
|
|
- Since: v0.3.0
|
|
|
|
|
2019-03-08 20:47:06 +02:00
|
|
|
|
|
|
|
Here is an example bash command using the Cloudflare provider:
|
|
|
|
|
|
|
|
```bash
|
2022-06-17 00:25:42 +02:00
|
|
|
CLOUDFLARE_EMAIL=you@example.com \
|
2019-03-08 20:47:06 +02:00
|
|
|
CLOUDFLARE_API_KEY=b9841238feb177a84330febba8a83208921177bffe733 \
|
2022-06-17 00:25:42 +02:00
|
|
|
lego --email you@example.com --dns cloudflare --domains my.example.org run
|
2019-09-01 14:32:20 +02:00
|
|
|
|
|
|
|
# or
|
|
|
|
|
2019-10-09 02:20:30 +02:00
|
|
|
CLOUDFLARE_DNS_API_TOKEN=1234567890abcdefghijklmnopqrstuvwxyz \
|
2022-06-17 00:25:42 +02:00
|
|
|
lego --email you@example.com --dns cloudflare --domains my.example.org run
|
2019-03-08 20:47:06 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Credentials
|
|
|
|
|
|
|
|
| Environment Variable Name | Description |
|
|
|
|
|-----------------------|-------------|
|
2019-07-04 18:10:43 +02:00
|
|
|
| `CF_API_EMAIL` | Account email |
|
|
|
|
| `CF_API_KEY` | API key |
|
2019-10-09 02:20:30 +02:00
|
|
|
| `CF_DNS_API_TOKEN` | API token with DNS:Edit permission (since v3.1.0) |
|
|
|
|
| `CF_ZONE_API_TOKEN` | API token with Zone:Read permission (since v3.1.0) |
|
2019-09-01 14:32:20 +02:00
|
|
|
| `CLOUDFLARE_API_KEY` | Alias to CF_API_KEY |
|
2019-10-09 02:20:30 +02:00
|
|
|
| `CLOUDFLARE_DNS_API_TOKEN` | Alias to CF_DNS_API_TOKEN |
|
2019-07-04 18:10:43 +02:00
|
|
|
| `CLOUDFLARE_EMAIL` | Alias to CF_API_EMAIL |
|
2019-10-09 02:20:30 +02:00
|
|
|
| `CLOUDFLARE_ZONE_API_TOKEN` | Alias to CF_ZONE_API_TOKEN |
|
2019-03-08 20:47:06 +02:00
|
|
|
|
2019-03-18 18:42:54 +02:00
|
|
|
The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
|
2024-08-14 23:55:11 +02:00
|
|
|
More information [here]({{% ref "dns#configuration-and-credentials" %}}).
|
2019-03-18 18:42:54 +02:00
|
|
|
|
2019-03-08 20:47:06 +02:00
|
|
|
|
|
|
|
## Additional Configuration
|
|
|
|
|
|
|
|
| Environment Variable Name | Description |
|
|
|
|
|--------------------------------|-------------|
|
2024-08-10 23:36:05 +02:00
|
|
|
| `CLOUDFLARE_HTTP_TIMEOUT` | API request timeout (in seconds) |
|
|
|
|
| `CLOUDFLARE_POLLING_INTERVAL` | Time between DNS propagation check (in seconds) |
|
|
|
|
| `CLOUDFLARE_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation (in seconds) |
|
|
|
|
| `CLOUDFLARE_TTL` | The TTL of the TXT record used for the DNS challenge (in seconds) |
|
2019-03-08 20:47:06 +02:00
|
|
|
|
2019-03-18 18:42:54 +02:00
|
|
|
The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
|
2024-08-14 23:55:11 +02:00
|
|
|
More information [here]({{% ref "dns#configuration-and-credentials" %}}).
|
2019-03-18 18:42:54 +02:00
|
|
|
|
2019-09-01 14:32:20 +02:00
|
|
|
## Description
|
|
|
|
|
2019-10-09 02:20:30 +02:00
|
|
|
You may use `CF_API_EMAIL` and `CF_API_KEY` to authenticate, or `CF_DNS_API_TOKEN`, or `CF_DNS_API_TOKEN` and `CF_ZONE_API_TOKEN`.
|
2019-09-01 14:32:20 +02:00
|
|
|
|
|
|
|
### API keys
|
|
|
|
|
|
|
|
If using API keys (`CF_API_EMAIL` and `CF_API_KEY`), the Global API Key needs to be used, not the Origin CA Key.
|
|
|
|
|
2019-10-09 02:20:30 +02:00
|
|
|
Please be aware, that this in principle allows Lego to read and change *everything* related to this account.
|
|
|
|
|
2019-09-01 14:32:20 +02:00
|
|
|
### API tokens
|
|
|
|
|
2019-10-09 02:20:30 +02:00
|
|
|
With API tokens (`CF_DNS_API_TOKEN`, and optionally `CF_ZONE_API_TOKEN`),
|
|
|
|
very specific access can be granted to your resources at Cloudflare.
|
|
|
|
See this [Cloudflare announcement](https://blog.cloudflare.com/api-tokens-general-availability/) for details.
|
|
|
|
|
|
|
|
The main resources Lego cares for are the DNS entries for your Zones.
|
2023-07-29 12:59:24 +02:00
|
|
|
It also needs to resolve a domain name to an internal Zone ID in order to manipulate DNS entries.
|
2019-10-09 02:20:30 +02:00
|
|
|
|
|
|
|
Hence, you should create an API token with the following permissions:
|
|
|
|
|
|
|
|
* Zone / Zone / Read
|
|
|
|
* Zone / DNS / Edit
|
|
|
|
|
|
|
|
You also need to scope the access to all your domains for this to work.
|
|
|
|
Then pass the API token as `CF_DNS_API_TOKEN` to Lego.
|
|
|
|
|
|
|
|
**Alternatively,** if you prefer a more strict set of privileges,
|
|
|
|
you can split the access tokens:
|
|
|
|
|
|
|
|
* Create one with *Zone / Zone / Read* permissions and scope it to all your zones.
|
|
|
|
This is needed to resolve domain names to Zone IDs and can be shared among multiple Lego installations.
|
|
|
|
Pass this API token as `CF_ZONE_API_TOKEN` to Lego.
|
|
|
|
* Create another API token with *Zone / DNS / Edit* permissions and set the scope to the domains you want to manage with a single Lego installation.
|
|
|
|
Pass this token as `CF_DNS_API_TOKEN` to Lego.
|
|
|
|
* Repeat the previous step for each host you want to run Lego on.
|
2019-09-01 14:32:20 +02:00
|
|
|
|
2019-10-09 02:20:30 +02:00
|
|
|
This "paranoid" setup is mainly interesting for users who manage many zones/domains with a single Cloudflare account.
|
|
|
|
It follows the principle of least privilege and limits the possible damage, should one of the hosts become compromised.
|
2019-03-08 20:47:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## More information
|
|
|
|
|
|
|
|
- [API documentation](https://api.cloudflare.com/)
|
|
|
|
- [Go client](https://github.com/cloudflare/cloudflare-go)
|
|
|
|
|
|
|
|
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|
|
|
|
<!-- providers/dns/cloudflare/cloudflare.toml -->
|
|
|
|
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|