Skip to content

dchidell/traefik-cloudflare-updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

traefik-cloudflare-updater

Instead of using a wildcard DNS record, create records dynamically using this.

Only works with traefikv2 configuration, look at the above repo for v1 support.

When you run the container, it'll update all the DNS records it can find, afterward it will sit and wait for any new traefik enabled containers to start and then updtae them. If this container restarts, it'll re-update everything.

Idea taken from the following GitHub repo: https://github.com/tiredofit/docker-traefik-cloudflare-companion

Why write this, and not use the above repo?

I didn't like the following things (just my preference):

  • No updating of existing records
  • No exclusions
  • Python 2
  • Stuff not needed for the operation of this service within the container
  • Bash and python mix

What I did like:

  • The general idea, wildcard domains are not nice
  • The fact it's at least in python
  • The elegant usage of docker events to update new containers

Usage

Example docker-compose.yml service:

dnsupdater:
image: dchidell/traefik-cloudflare-updater
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
- [email protected]
- CF_TOKEN=1234567890
- TARGET_DOMAIN=example.com
- DOMAIN1=mydomain1.com
- DOMAIN1_ZONE_ID=1234567890
- DOMAIN2=mydomain2.com
- DOMAIN2_ZONE_ID=1234567890
- EXCLUDED_DOMAINS=static.mydomain1.com,test.mydomain2.com

Mandatory ENV vars:

CF_GLOBAL_KEY - CloudFlare API Key (This must be the GLOBAL key)

and

CF_EMAIL - CloudFlare API Email

Both CF_GLOBAL_KEY and CF_EMAIL are required if using the GLOBAL key.

or

CF_TOKEN (recommended) - CloudFlare API Token (This must be a user token, NOT the global key)

See https://github.com/cloudflare/python-cloudflare#providing-cloudflare-username-and-api-key for detailed information on CF authentication.

TARGET_DOMAIN - a CNAME will be created pointing to this target

DOMAIN# - Multiple of these per domain, e.g. DOMAIN1=example.com, DOMAIN2=example.net ... DOMAINn=example.org

DOMAIN#_ZONE_ID - CloudFlare zone ID for domain index.

Optional ENV vars:

DOMAIN#_PROXIED - Whether to use CloudFlare proxy. Should be 'TRUE' or 'FALSE' (not 1 or 0) (defaults to TRUE)

EXCLUDED_DOMAINS - Comma separated domains to be excluded from updating (i.e. if you want to statically define something) e.g. EXCLUDED_DOMAINS=sub.domain.com,sub2.domain.com

DOMAIN#_CF_TOKEN - Override domain.com CloudFlare token (

DOMAIN#_CF_EMAIL - Override domain.com CloudFlare email

DOMAIN#_CF_GLOBAL_KEY - Override domain.com CloudFlare global key

About

Updates CloudFlare with traefik configuration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published