mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Merge branch 'master' into tlim_cfaliases
This commit is contained in:
@ -22,13 +22,14 @@ username and access token:
|
||||
## Metadata
|
||||
|
||||
Record level metadata availible:
|
||||
* cloudflare_proxy ('on', 'off', or 'full')
|
||||
* `cloudflare_proxy` ("on", "off", or "full")
|
||||
|
||||
Domain level metadata availible:
|
||||
* cloudflare_proxy_default ('on', 'off', or 'full')
|
||||
* `cloudflare_proxy_default` ("on", "off", or "full")
|
||||
|
||||
Provider level metadata availible:
|
||||
* ip_conversions
|
||||
* `ip_conversions`
|
||||
* `manage_redirects`: set to `true` to manage page-rule based redirects
|
||||
|
||||
What does on/off/full mean?
|
||||
|
||||
@ -100,3 +101,31 @@ DNSControl depends on a Cloudflare Global API Key that's available under "My Set
|
||||
If a domain does not exist in your CloudFlare account, DNSControl
|
||||
will *not* automatically add it. You'll need to do that via the
|
||||
control panel manually or via the `dnscontrol create-domains` command.
|
||||
|
||||
## Redirects
|
||||
|
||||
The cloudflare provider can manage Page-Rule based redirects for your domains. Simply use the `CF_REDIRECT` and `CF_TEMP_REDIRECT` functions to make redirects:
|
||||
|
||||
{% highlight js %}
|
||||
|
||||
// chiphacker.com is an alias for electronics.stackexchange.com
|
||||
|
||||
D("chiphacker.com", REG_NAMECOM, DnsProvider(CFLARE),
|
||||
// must have A records with orange cloud on. Otherwise page rule will never run.
|
||||
A("@","1.2.3.4", CF_PROXY_ON),
|
||||
A("www", "1.2.3.4", CF_PROXY_ON)
|
||||
A("meta", "1.2.3.4", CF_PROXY_ON),
|
||||
|
||||
// 302 for meta subdomain
|
||||
CF_TEMP_REDIRECT("meta.chiphacker.com/*", "https://electronics.meta.stackexchange.com/$1),
|
||||
|
||||
// 301 all subdomains and preserve path
|
||||
CF_REDIRECT("*chiphacker.com/*", "https://electronics.stackexchange.com/$2),
|
||||
);
|
||||
{%endhighlight%}
|
||||
|
||||
Notice a few details:
|
||||
|
||||
1. We need an A record with cloudflare proxy on, or the page rule will never run.
|
||||
2. The IP address in those A records may be mostly irrelevant, as cloudflare should handle all requests (assuming some page rule matches).
|
||||
3. Ordering matters for priority. CF_REDIRECT records will be added in the order they appear in your js. So put catch-alls at the bottom.
|
||||
|
Reference in New Issue
Block a user