mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-07 05:34:43 +08:00
Update alias examples in cloudflare doc
This commit is contained in:
parent
806621e115
commit
b620121dce
1 changed files with 46 additions and 32 deletions
|
@ -22,57 +22,72 @@ username and access token:
|
||||||
## Metadata
|
## Metadata
|
||||||
|
|
||||||
Record level metadata availible:
|
Record level metadata availible:
|
||||||
* cloudflare_proxy ("on", "off", or "full")
|
* cloudflare_proxy ('on', 'off', or 'full')
|
||||||
|
|
||||||
Domain level metadata availible:
|
Domain level metadata availible:
|
||||||
* cloudflare_proxy_default ("on", "off", or "full")
|
* cloudflare_proxy_default ('on', 'off', or 'full')
|
||||||
|
|
||||||
Provider level metadata availible:
|
Provider level metadata availible:
|
||||||
* ip_conversions
|
* ip_conversions
|
||||||
|
|
||||||
Note: Aliases are pre-defined as follows:
|
What does on/off/full mean?
|
||||||
|
|
||||||
|
* "off" disables the Cloudflare proxy
|
||||||
|
* "on" enables the Cloudflare proxy (turns on the "orange cloud")
|
||||||
|
* "full" is the same as "on" but also enables Railgun. DNSControl will prevent you from accidentally enabling "full" on a CNAME that points to an A record that is set to "off", as this is generally not desired.
|
||||||
|
|
||||||
|
**Aliases:**
|
||||||
|
|
||||||
|
To make configuration files more readable and less prone to typos,
|
||||||
|
the following aliases are pre-defined:
|
||||||
|
|
||||||
{% highlight json %}
|
{% highlight json %}
|
||||||
var CF_PROXY_OFF = {'cloudflare_proxy': 'off'}; // Default/off.
|
// Meta settings for individual records.
|
||||||
var CF_PROXY_ON = {'cloudflare_proxy': 'on'}; // Sites safe to proxy.
|
var CF_PROXY_OFF = {'cloudflare_proxy': 'off'}; // Proxy disabled.
|
||||||
var CF_PROXY_FULL = {'cloudflare_proxy': 'full'}; // Sites safe to railgun.
|
var CF_PROXY_ON = {'cloudflare_proxy': 'on'}; // Proxy enabled.
|
||||||
var SET_PROXY_DEFAULT_TRUE = CF_PROXY_ON; // Turn on CF proxy for entire domain.
|
var CF_PROXY_FULL = {'cloudflare_proxy': 'full'}; // Proxy+Railgun enabled.
|
||||||
var SET_PROXY_DEFAULT_FALSE = CF_PROXY_OFF; // basically a no-op.
|
// Per-domain meta settings:
|
||||||
|
// Proxy default off for entire domain (the default):
|
||||||
|
var CF_PROXY_DEFAULT_OFF = {'cloudflare_proxy_default': 'off'};
|
||||||
|
// Proxy default on for entire domain:
|
||||||
|
var CF_PROXY_DEFAULT_ON = {'cloudflare_proxy_default': 'on'};
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
Thus metadata items can be used in a more readable way:
|
The following example shows how to set meta variables with and without aliases:
|
||||||
|
|
||||||
{% highlight json %}
|
{% highlight json %}
|
||||||
D("example.tld", REG_NAMECOM, DnsProvider(CFLARE),
|
D('example.tld', REG_NAMECOM, DnsProvider(CFLARE),
|
||||||
A("www1","1.2.3.11", CF_PROXY_ON),
|
A('www1','1.2.3.11', CF_PROXY_ON), // turn proxy ON.
|
||||||
A("www2","1.2.3.12", CF_PROXY_OFF), // default is OFF, this is a no-op.
|
A('www2','1.2.3.12', CF_PROXY_OFF), // default is OFF, this is a no-op.
|
||||||
|
A('www3','1.2.3.13', {'cloudflare_proxy': 'on'}) // why would anyone do this?
|
||||||
);
|
);
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
or simply:
|
|
||||||
|
|
||||||
{% highlight json %}
|
|
||||||
D("example.tld", REG_NAMECOM, DnsProvider(CFLARE),
|
|
||||||
SET_PROXY_DEFAULT_TRUE, // Enable CF proxy for all items:
|
|
||||||
A("www1","1.2.3.11"),
|
|
||||||
A("www2","1.2.3.12"),
|
|
||||||
A("www3","1.2.3.13", CF_PROXY_OFF), // Except this one!
|
|
||||||
);
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Example javascript:
|
Example javascript:
|
||||||
|
|
||||||
{% highlight js %}
|
{% highlight js %}
|
||||||
var REG_NAMECOM = NewRegistrar("name.com","NAMEDOTCOM");
|
var REG_NAMECOM = NewRegistrar('name.com','NAMEDOTCOM');
|
||||||
var CFLARE = NewDnsProvider("cloudflare.com","CLOUDFLAREAPI");
|
var CFLARE = NewDnsProvider('cloudflare.com','CLOUDFLAREAPI');
|
||||||
|
|
||||||
D("example.tld", REG_NAMECOM, DnsProvider(CFLARE),
|
// Example domain where the CF proxy abides by the default (off).
|
||||||
A("test","1.2.3.4"),
|
D('example.tld', REG_NAMECOM, DnsProvider(CFLARE),
|
||||||
A("www","1.2.3.4", {cloudlfare_proxy:"on"}),
|
A('proxied','1.2.3.4', CF_PROXY_ON),
|
||||||
ALIAS("@","test.example.tld",{cloudflare_proxy:"on"})
|
A('notproxied','1.2.3.5'),
|
||||||
|
A('another','1.2.3.6', CF_PROXY_ON),
|
||||||
|
ALIAS('@','www.example.tld.', CF_PROXY_ON),
|
||||||
|
CNAME('myalias','www.example.tld.', CF_PROXY_ON)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Example domain where the CF proxy default is set to "on":
|
||||||
|
D('example2.tld', REG_NAMECOM, DnsProvider(CFLARE),
|
||||||
|
CF_PROXY_DEFAULT_ON, // Enable CF proxy for all items unless otherwise noted.
|
||||||
|
A('proxied','1.2.3.4'),
|
||||||
|
A('notproxied','1.2.3.5', CF_PROXY_OFF),
|
||||||
|
A('another','1.2.3.6'),
|
||||||
|
ALIAS('@','www.example2.tld.'),
|
||||||
|
CNAME('myalias','www.example2.tld.')
|
||||||
);
|
);
|
||||||
{%endhighlight%}
|
{%endhighlight%}
|
||||||
|
|
||||||
|
@ -84,5 +99,4 @@ 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
|
If a domain does not exist in your CloudFlare account, DNSControl
|
||||||
will *not* automatically add it. You'll need to do that via the
|
will *not* automatically add it. You'll need to do that via the
|
||||||
control panel manually or via the command `dnscontrol create-domains`
|
control panel manually or via the `dnscontrol create-domains` command.
|
||||||
-command.
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue