syncflaer

module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: GPL-3.0

README

SyncFlaer

Synchronize Traefik host rules with Cloudflare®.

Docker Image Version (latest semver) Docker Pulls GitHub go.mod Go version

Why?

  • Dynamically create, update or delete Cloudflare® DNS records based on Traefik http rules
  • Update DNS records when public IP changes
  • Supports configuring additional DNS records for services outside Traefik (i.e. vpn server)

Contents

Usage

Simple

Create a config file based on the example located at examples/config.yml.

syncflaer -config-path /opt/syncflaer.yml

Flags:

Usage of SyncFlaer:
  -config-path string
    	Path to config file (default "config.yml")
  -debug
    	Enable debug mode
  -version
    	Print the current version and exit
Kubernetes

You can run SyncFlaer as a Kubernetes CronJob. For an example deployment, please refer to the files located at examples/deploy.

Configuration

Overview

SyncFlaer must be configured via a YAML config file. Some secrets can be configured using environment variables.

Minimal Config File

The following configuration is required.

---
traefik:
  url: https://traefik.example.com

cloudflare:
  email: mail@example.com
  apiKey: abc  # can also be set using CLOUDFLARE_APIKEY env variable
  zoneName: example.com
Full Config File
---
# a list of services that return the public IP
ipProviders:
  - https://ifconfig.me/ip
  - https://ipecho.net/plain
  - https://myip.is/ip

# configure Slack notifications for SyncFlaer
notifications:
  slack:
    # Slack webhook URL
    webhookURL: https://hooks.slack.com/services/abc/def  # can also be set using SLACK_WEBHOOK env variable
    username: SyncFlaer
    channel: "#syncflaer"
    iconURL: https://url.to/image.png

traefik:
  # base URL for Traefik dashboard and API (https://doc.traefik.io/traefik/operations/api/)
  url: https://traefik.example.com
  # HTTP basic auth credentials for Traefik
  username: admin
  password: supersecure  # can also be set using TRAEFIK_PASSWORD env variable
  # a list of rules which will be ignored
  # these rules are matched as a substring of the entire Traefik rule (i.e test.local.example.com would also match)
  ignoredRules:
    - local.example.com
    - dev.example.com

# specify additional DNS records for services absent in Traefik (i.e. vpn server)
additionalRecords:
  - name: vpn.example.com
    ttl: 120
  - name: a.example.com
    proxied: true
    type: A
    contents: 1.1.1.1

cloudflare:
  # your Cloudflare account email
  email: mail@example.com
  # global Cloudflare API key
  apiKey: abc  # can also be set using CLOUDFLARE_APIKEY env variable
  # essentially the root domain of your services
  zoneName: example.com
  # define how many skips should happen until a DNS record gets deleted
  # every run of SyncFlaer counts as a skip
  deleteGrace: 5
  # define a set of defaults applied to all Traefik rules
  defaults:
    type: CNAME
    proxied: true
    ttl: 1
Environment Variables

Note: Environment variables have a higher precedence than the config file!

Name Description
SLACK_WEBHOOK Slack Webhook URL
TRAEFIK_PASSWORD Password for Traefik dashboard (HTTP basic auth)
CLOUDFLARE_APIKEY Cloudflare API key
Defaults

If not specified, the following defaults apply:

Name Default Value
ipProviders ["https://ifconfig.me/ip", "https://ipecho.net/plain", "https://myip.is/ip"]
cloudflare.deleteGrace 0 (delete records instantly)
cloudflare.defaults.type CNAME
cloudflare.defaults.proxied false
cloudflare.defaults.ttl 1
notifications.slack.username SyncFlaer
notifications.slack.iconURL https://www.cloudflare.com/img/cf-facebook-card.png
Additional Records

You can specify additional DNS records which are not configured as Traefik hosts.

Example A Record
Key Example Default Value Required
name a.example.com none yes
type A cloudflare.defaults.type no
ttl 1 cloudflare.defaults.ttl no
content 1.1.1.1 current public IP no
proxied true false no
Example CNAME Record
Key Example Default Value Required
name vpn.example.com none yes
type CNAME cloudflare.defaults.type no
ttl 120 cloudflare.defaults.ttl no
content mysite.com cloudflare.zoneName no
proxied false false no

2021 Containeroo

Cloudflare and the Cloudflare Logo are registered trademarks owned by Cloudflare Inc. This project is not affiliated with Cloudflare®.

License

GNU GPLv3

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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