tiredofit / docker-traefik-cloudflare-companion

Automatically Create CNAME records for containers served by Traefik

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Dynamic Configs

whizzzkid opened this issue · comments

Description of the feature
Traefik supports dynamic configurations via providers: https://doc.traefik.io/traefik/getting-started/configuration-overview/#the-dynamic-configuration. I use this to proxy other internal services running on different internal hosts to be accessible externally.

However, the urls that configured dynamically do not get registered with cloudflare. It works locally, but not accessible via cloudflare. A work-around is to manually insert CNAME records in Cloudflare's DNS config, however it's just a hassle everytime I want a new service online

Benftits of feature
Dynamic Configurations are supposed to work just like static urls, but cloudflare companion does not support it.

Additional context
No additional context.

You can add a label e.g. "traefik.http.routers.cf-companion1-rtr.rule=Host(host.mydomain.com)" this will force cf-companion to create the CNAMEs since cf-companion creates CNAMEs based on host rules. This is faster then logging into cloudflare and doing i manually.

However I'm also looking for a way to do this dynamically!!!

One "easy" way would be to query traefik at /api/http/routers and find all those routers with a Host rule like:

"Host(`<SERVICE><CLOUDFLARE_DOMAIN_PATTERN>`)"

It would have to be polling, because Traefik doesn't have an event. The routers discovered this way would need to be de-duped against those discovered from container labels.

@whizzzkid @ahmaddxb Can you try PR #59 and see if it does what you want?

@whizzzkid @ahmaddxb Merged and released as 6.8.0

@tiredofit Can this be closed?

Yes it can, thank you!