CDN Host Mode
Overview
You can use a CDN (Content Delivery Network) with WP Squared. After you enable CDN host mode, your server synchronizes new and updated DNS records to the CDN. When you create a domain in WHM or WP Squared, your server automatically creates the domain’s DNS records on the CDN nameservers.
For example, if you enable CDN host mode with Cloudflare® credentials and create a domain in WHM or WP Squared, your server creates the domain’s DNS records on Cloudflare. If you later change those records, the server updates them.
- Currently, WP Squared only supports Cloudflare.
- If you enable CDN host mode, the system disables WP Squared’s Content Delivery Network interface.
What is a CDN?
A Content Delivery Network (CDN) uses servers in various locations to provide online content from the closest server to the website consumer, making websites load faster. A properly configured CDN may also help protect websites against some common malicious attacks, such as Distributed Denial of Service (DDOS) attacks.
Enable CDN host mode
To enable CDN host mode, you can use WHM API 1’s cdn_defaultconfig_set function. This function configures your server’s CDN settings.
Use your email address and API key
You will need the following information before you run the API:
| Item | Description | Example |
|---|---|---|
| Email address | The email address you use to authenticate with the CDN service. You would use your email address with your API key. | username@example.com |
| API key | The API key you use to authenticate with the CDN service. You would use your email address with your API key. | Click to view…23ZX8RA1FTE1IVJRL90MB5CREDS4UE2H |
To run the API, you can use WHM’s Terminal interface. In the following example, replace the values for api_key and email with the credentials you obtained from your CDN:
whmapi1 cdn_defaultconfig_set api_key="23ZX8RA1FTE1IVJRL90MB5CREDS4UE2H" email="username@example.com"
Use an API token
You will need the following information before you run the API:
| Item | Description | Example |
|---|---|---|
| API token | The API token you use to authenticate with the CDN service. The API requires no additional parameters. | Click to view…23ZX8RA1FTE1IVJRL90MB5CREDS4UE2H |
To run the API, you can use WHM’s Terminal interface. In the following example, replace the value for token with the credentials you obtained from your CDN:
whmapi1 cdn_defaultconfig_set token="23ZX8RA1FTE1IVJRL90MB5CREDS4UE2H"
Disable CDN host mode
To disable CDN host mode, run WHM API 1’s cdn_defaultconfig_disable function in WHM’s Terminal interface. This function:
- Disables all of the CDN’s default configuration settings.
- Records an explicit opt-out in the
/var/cpanel/cdn/default.configfile. This opt-out keeps CDN host mode disabled. - Removes the
CDNmember from your server’s DNS cluster. This function does not change the server-wide DNS clustering setting.
whmapi1 cdn_defaultconfig_disable
This function does not have any parameters.
CDN host mode stays disabled through upcp runs, reboots, and snapshots. Your CDN credentials persist. To re-enable CDN host mode, run the cdn_defaultconfig_set function with at least one parameter.
If the system cannot remove the CDN member from the DNS cluster, the opt-out still takes effect. The function returns a metadata.result value of 0 and a message that instructs you to run the function again.
- WHM API 1’s
cdn_defaultconfig_disablefunction does not change existing website settings or DNS records. - If you ran
cdn_defaultconfig_disablebefore you updated to WP Squared version 11.138.1.15, run the function again after the update. This step makes the opt-out take effect.
Re-enable CDN host mode
To re-enable CDN host mode after you disable it, run the cdn_defaultconfig_set function with at least one parameter. Use the same steps as in the Enable CDN host mode section. If you run the function with no parameters, it changes nothing and CDN host mode stays disabled. When you run the function with a parameter, it adds the CDN member back to your server’s DNS cluster and clears the opt-out.
If the system cannot re-add the CDN member, the function saves your settings but returns a metadata.result value of 0. CDN host mode remains disabled. Run the function again to resolve the issue.
Check the CDN status
To confirm whether CDN host mode is disabled, run WHM API 1’s cdn_defaultconfig_status function in WHM’s Terminal interface. The function’s output includes the disabled flag. Run the following command:
whmapi1 cdn_defaultconfig_status