feat(traefik): support Cloudflare DNS-01 ACME challenge

This commit is contained in:
2026-06-01 10:09:28 +03:30
parent 57284c07d4
commit ba958fd67d
4 changed files with 68 additions and 4 deletions

View File

@@ -248,15 +248,37 @@ OpenCloud Compose supports adding SSL certificates for public domains and develo
### Use Let's Encrypt with ACME Challenge
1. **Enable Let's Encrypt**:
- Set `TRAEFIK_LETSENCRYPT_EMAIL` to your email address for the ACME challenge
- Set `TRAEFIK_ACME_MAIL` to your email address for the ACME challenge
- Set `TRAEFIK_SERVICES_TLS_CONFIG="tls.certresolver=letsencrypt"` to use Let's Encrypt (default value)
```bash
# In your .env file
TRAEFIK_LETSENCRYPT_EMAIL=devops@your-domain.tld
TRAEFIK_ACME_MAIL=devops@your-domain.tld
TRAEFIK_SERVICES_TLS_CONFIG="tls.certresolver=letsencrypt"
```
2. **Use DNS-01 challenge with Cloudflare (recommended if Let's Encrypt cannot reach your server)**:
- Set `TRAEFIK_ACME_CHALLENGE=dns`
- Set `TRAEFIK_ACME_DNS_PROVIDER=cloudflare`
- Set `CF_DNS_API_TOKEN` to a Cloudflare token with DNS edit permissions for your zone
```bash
# In your .env file
TRAEFIK_ACME_MAIL=devops@your-domain.tld
TRAEFIK_SERVICES_TLS_CONFIG="tls.certresolver=letsencrypt"
TRAEFIK_ACME_CHALLENGE=dns
TRAEFIK_ACME_DNS_PROVIDER=cloudflare
CF_DNS_API_TOKEN=your-cloudflare-token
# Optional: helps in split-DNS environments
# TRAEFIK_ACME_DNS_RESOLVERS=1.1.1.1:53,8.8.8.8:53
```
Then restart Traefik:
```bash
docker compose up -d traefik
```
### Use Certificates from the `certs/` directory
1. **Place your certificates**:
@@ -342,8 +364,11 @@ Key variables:
| `LDAP_BIND_PASSWORD` | LDAP password for the bind user | admin |
| `KC_DB_USERNAME` | Database user for keycloak | keycloak |
| `KC_DB_PASSWORD` | Database password for keycloak | keycloak |
| `TRAEFIK_LETSENCRYPT_EMAIL` | Email Address for the Let's Encrypt ACME challenge | example@example.org |
| `TRAEFIK_ACME_MAIL` | Email Address for the Let's Encrypt ACME challenge | example@example.org |
| `TRAEFIK_SERVICES_TLS_CONFIG` | Tell traefik and the services which TLS config to use | tls.certresolver=letsencrypt |
| `TRAEFIK_ACME_CHALLENGE` | ACME challenge type (http, dns, tls) | http |
| `TRAEFIK_ACME_DNS_PROVIDER` | DNS provider for ACME DNS challenge | cloudflare |
| `CF_DNS_API_TOKEN` | Cloudflare token used for DNS-01 challenge | (no value) |
| `TRAEFIK_CERTS_DIR` | Directory for custom certificates. | ./certs |
See `.env.example` for all available options and their documentation.