How to Create a CDN with cPanel and Bunny.net
A content delivery network, or CDN, stores cached copies of your files on servers around the world. Visitors can then download images, CSS, JavaScript, videos, and other static files from a location closer to them.
This guide explains how to create a CDN using a cPanel hosting account and Bunny.net. We will use the Web Host Pro CDN as a real example:
- Origin URL:
https://origin.webhostpro.com - Public CDN URL:
https://cdn.webhostpro.com
Your origin URL stores the original files. Your public CDN URL delivers cached copies of those files through Bunny.net.
Web Host Pro customers: We can help create and configure your Bunny.net CDN at no additional charge. Contact support after creating your Bunny.net account.Before You Begin
You will need:
- A domain hosted on a cPanel account
- Access to cPanel
- Control over the domain's DNS records
- A Bunny.net account
Create your Bunny.net account here
Step 1: Choose Your CDN Subdomains
We recommend using two subdomains:
origin.yourdomain.comstores the original files on your cPanel account.cdn.yourdomain.comis the public address connected to Bunny.net.
Our working example uses:
origin.webhostpro.comcdn.webhostpro.com
Do not use the CDN hostname as the Bunny origin. Bunny must retrieve files from the separate origin hostname.
Step 2: Create the Origin Subdomain in cPanel
- Log in to cPanel.
- Open Domains.
- Click Create a New Domain.
- Enter your origin subdomain, such as
origin.yourdomain.com. - Choose a document root for the CDN files.
- Click Submit.
A typical document root would be:
/public_html/origin
For the Web Host Pro example, files available inside the origin document root can be accessed through:
https://origin.webhostpro.com/filename.jpg
Step 3: Upload a Test File
- Open File Manager in cPanel.
- Open the origin subdomain's document root.
- Upload a small image or text file.
- Open the file directly through the origin URL.
For example:
https://origin.webhostpro.com/test-image.jpg
Do not continue until the file loads successfully over HTTPS. Bunny.net cannot retrieve a file that is missing, blocked, or inaccessible from the origin URL.
Step 4: Create a Pull Zone in Bunny.net
- Log in to your Bunny.net account.
- Click Add Pull Zone.
- Enter a name for the Pull Zone.
- Enter your origin URL.
- Select your preferred pricing zone or network options.
- Click Add Pull Zone.
For the Web Host Pro example, the origin URL is:
https://origin.webhostpro.com
Bunny will also create a temporary hostname similar to:
yourzonename.b-cdn.net
Save this hostname. You will use it when creating the CDN DNS record.
Step 5: Test the Bunny Pull Zone
Before adding your custom CDN hostname, test the Bunny hostname with the file you uploaded.
For example:
https://yourzonename.b-cdn.net/test-image.jpg
Bunny should retrieve the file from your origin server and deliver it through its CDN.
If the file does not load, check:
- The origin URL is entered correctly.
- The file loads directly from the origin hostname.
- The filename and capitalization match exactly.
- The origin server is not blocking Bunny.net.
- The origin has a working SSL certificate.
Step 6: Add Your Custom CDN Hostname
- Open your Pull Zone in Bunny.net.
- Open General.
- Find the Hostnames section.
- Add your public CDN hostname, such as
cdn.yourdomain.com.
Our example hostname is:
cdn.webhostpro.com
Step 7: Create the CDN CNAME Record in cPanel
- Log in to cPanel.
- Open Zone Editor.
- Find your domain and click Manage.
- Click Add Record.
- Select CNAME as the record type.
- Enter your CDN hostname in the Name field.
- Enter the Bunny Pull Zone hostname in the CNAME or Record field.
- Save the record.
The record should look similar to this:
| Type | Name | Points To |
|---|---|---|
| CNAME | cdn.yourdomain.com |
yourzonename.b-cdn.net |
For our Web Host Pro setup:
cdn.webhostpro.com → Web Host Pro's Bunny Pull Zone hostname
Important: Remove any existing A, AAAA, or CNAME record using the same cdn hostname before adding the new CNAME record. A hostname cannot use conflicting DNS records.
Step 8: Enable SSL in Bunny.net
DNS changes can take several minutes to begin working. Once Bunny confirms that the CNAME record is correct:
- Return to your Pull Zone.
- Open General and find Hostnames.
- Locate your custom CDN hostname.
- Enable the free SSL certificate.
- Enable Force SSL so requests always use HTTPS.
Your files should now load through your custom CDN URL:
https://cdn.yourdomain.com/test-image.jpg
Our example would be:
https://cdn.webhostpro.com/test-image.jpg
Step 9: Start Using the CDN
Replace the origin URL with the CDN URL when linking to files on your website.
Original file URL:
https://origin.webhostpro.com/images/example.jpg
Public CDN URL:
https://cdn.webhostpro.com/images/example.jpg
Example HTML image:
<img src="https://cdn.webhostpro.com/images/example.jpg" alt="Example image">
Example stylesheet:
<link rel="stylesheet" href="https://cdn.webhostpro.com/css/style.css">
Example JavaScript file:
<script src="https://cdn.webhostpro.com/js/app.js"></script>
Step 10: Configure Caching
Bunny.net provides default caching settings that work for many static files. You can adjust these settings inside the Pull Zone under Caching.
Files commonly delivered through a CDN include:
- Images
- CSS stylesheets
- JavaScript files
- Fonts
- Videos
- Software downloads
- PDF documents
Avoid aggressively caching pages or files that contain customer-specific, account-specific, or frequently changing information unless you understand the cache rules being used.
Updating Files and Clearing the Cache
Updating a file on the origin server does not always remove the older cached copy immediately.
After replacing a file, you can:
- Open the Pull Zone in Bunny.net.
- Open the cache management or purge section.
- Purge the individual file URL or clear the Pull Zone cache.
Purging only the changed file is normally better than clearing the entire CDN cache.
Common Problems
The CDN URL Shows an SSL Error
Confirm that the CDN hostname has a CNAME record pointing to the Bunny Pull Zone hostname. Bunny cannot activate its certificate until the hostname resolves correctly.
The CDN URL Returns a 404 Error
Open the same path using the origin URL. If the file does not exist at the origin, Bunny cannot retrieve it.
The CDN Shows an Older Version of a File
Purge that file from the Bunny cache or rename the file when uploading the updated version.
The CNAME Record Cannot Be Added
Delete any existing A, AAAA, or CNAME record using the same CDN hostname, then create the Bunny CNAME record again.
The Origin Is Behind Cloudflare
Bunny should be able to connect directly to the origin server. Security rules, bot protection, rate limits, or another proxy service can sometimes block Bunny from retrieving files.
When using Cloudflare DNS for the CDN hostname, keep the Bunny CNAME record set to DNS only while validating and issuing the SSL certificate.
Final Setup Checklist
- The origin subdomain loads over HTTPS.
- The test file loads directly from the origin.
- The Bunny Pull Zone uses the correct origin URL.
- The test file loads through the Bunny hostname.
- The custom CDN hostname has been added to Bunny.
- The CDN hostname points to Bunny with a CNAME record.
- Free SSL and Force SSL are enabled.
- The test file loads through the custom CDN URL.
Free CDN Setup Help for Web Host Pro Customers
Web Host Pro customers can contact our support team for free help setting up a Bunny.net CDN with their cPanel hosting account.
We can help with:
- Creating the origin subdomain
- Creating the Bunny.net Pull Zone
- Connecting the custom CDN hostname
- Adding the correct DNS record
- Activating SSL
- Testing the CDN
- Troubleshooting common origin and caching problems
Create a Bunny.net account and then contact Web Host Pro support with the domain and CDN hostname you would like to use.