Do you want to configure StackPath CDN for your Discourse forum but couldn’t find any comprehensive guide? I had the same problem, so I created this step-by-step guide.

To make this guide easy to follow, I divided it into sections. In the first section, you’ll create a StackPath account and create a Site in StackPath.
Then, in the second section, you’ll edit your DNS record to create a CNAME for the CDN URL. Next up, in section three, I have the steps to update your Discourse app.yml file with the CDN entries and rebuild the container.
Not only that, but step three also shows you how to test that your CDN works. As a bonus, I included an FAQ section where I answer questions about configuring CDN for your Discourse forum.
How to Create a StackPath Account and Configure Your StackPath CDN

As I mentioned in my introduction, the first step to configuring StackPath CDN for your Discourse forum is to create a StackPath account. Then, create your StackPath “Site”.
Follow the steps below to complete these tasks:
- Open stackpath.com and create an account. To create an account, on the top right of the stackpath.com homepage, click Get Started.


- Once you have created a StackPath account, control.stackpath.com. Then, on the top right of your StackPath Dashboard, click Create Site.

- On the Create a Site // Select an Integration page, click Select Full Site.

- On the Create a Site // Full Site Integration page, enter the URL of your Discourse forum. In this example, I am using the URL of Itechguides Community forum, community.www.itechguides.com.
- After entering the URL, check the box beside the Content Delivery Network (CDN) option, scroll down and click Add to subscription.


- When you click the Add to subscription button, StackPath will require you to confirm the subscription. When I published this article, StackPath was charging $25/m for this service.
If you wish to continue, click Continue. It will take a few seconds for this stage to complete. Once completed, proceed to step 7 below.

- To proceed to the next step, click Set Up Your Origin.

- On the next page, StackPath will display the IP address of your Discourse forum in the “Origin Hostname / IP Address” field. Confirm that it is the correct IP address.
Then, scroll down to the “Do you want to add a custom domain (for example, cdn.yourdomain.com)?” and select Yes. When you select Yes, the Confirm Origin Address button will change to Add Delivery Domains. - To proceed to the next step, click Add Delivery Domains.


- When the Add Delivery Domains page opens, your Discourse forum (added earlier) will be displayed.
Beneath your Discourse forum’s URL, add your CDN subdomain. Then, click the Add button. - Once your CDN subdomain has been added, click Confirm Delivery Domains.


- Then, on the “Select an SSL Method (Optional)” page, accept the defaults. Then, scroll down and click Accept SSL Method.

- Once you click Accept SSL Method, the Validate with DNS Challenge page will be displayed. You will use the information displayed here to validate your ownership of your Discourse forum URL domain.
You will complete this task in the next section.

Verify the Ownership of Your Domain with StackPath (Example with Cloudflare-Hosted DNS)

This is the next step to configuring CDN for your Discourse forum is to verify your domain.
- Login to your DNS provider’s site, locate manage DNS and click Add. If you use Cloudflare, log in to Cloudflare, then, open your active domain hosted by Cloudflare.

- Then, on the left pane of the left pane, click DNS.

- On the DNS management page for your domain, create two CNAME entries – one for your CDN domain, and the second for the forum domain. In my example, community.www.itechguides.com, and community-CDN.www.itechguides.com.


- Back to your StackPath setup page, expand the “Validate with HTTP Request” section. Then, in your DNS provider, create a CNAME record for your CDN domain.
Use the information provided by StackPath.
If you use Cloudflare, make sure to turn Proxy status off.

- Still, on the StackPath website, scroll down and check “I have completed one of the above validation steps to verify I own the domain.”. Then, click Verify Domain Ownership.

- Once StackPath has verified that you own the primary domain, it will display the information you require to Update Your DNS.
- Open the DNS management on your DNS provider’s page and create the A record. StackPath will display the information you require on the Update Your DNS page.
There is one more step to complete the configuration of CDN for Discourse with StackPath. See the next section for details.
- Finally, check the “I have completed the above steps to point my DNS to StackPath.” box. Then, click Complete Setup.


Update Your Discourse App.yml File with the StackPath CDN URL

This is the final stage to configure CDN for Discourse with StackPath.
- SSH to your Discourse host server. Then, run the commands below. The second command will open your Discourse app.yml file for editing.
cd /var/discourse nano containers/app.yml
- When the app.yml opens, uncomment the CDN line and update it with the CDN CNAME you set up in your DNS. Before you uncomment the CDN line, it will look like the highlighted portion of the screenshot below.

- Now, remove # in front of DISCOURSE_CDN_URL: https://discourse-cdn.example.com and change “https://discourse-cdn.example.com” to your CDN URL. When you finish, the CDN line will look like this:
DISCOURSE_CDN_URL: https://community-CDN.www.itechguides.com

- When you’re happy with the changes to the app.yml, pres Ctrl and X keys on your keyboard simultaneously. Then, app.yml will prompt you to save the file – type Y and press enter.
- Finally, to rebuild your Discourse container for the changes you made to take effect, run the two commands below.
cd /var/discourse ./launcher rebuild app

- Wait for Discourse to complete the container rebuild. Then, to confirm that your static assets are now served via the CDN, open your forum in a browser.
- Then, right-click anywhere on a page and click Inspect.

- Next, click the >> next to Elements and select Network.

- Finally, refresh the page by pressing F5. If you point to an asset, StackPath should now serve the static assets from your CDN URL.

Frequently Asked Questions About Configuring StackPath CDN for Discourse Forum

Discourse CDN means to enable CDN for your Discourse forum. Enabling CD for your Discourse forum means that your Discourse forum’s static assets are served from the CDN provider’s wide network across the globe.
The implication is that your forum loads faster for your visitors.
To create a domain CDN, add the CDN URL when you configure CDN on your provider’s site. When you do this, your provider will display the A and CNAME records you need to add to your DNS provider.
Next, open your account on your DNS provider’s website and create the A and CNAME records. The A DNS record will point your original domain URL to your CDN provider’s provided IP address.
On the other hand, the CNAME record will point your CDN domain to the CDN URL your CDN provided assigned to your domain when you signed up.
No, Discord is different from Discourse. While the two names may sound similar, they are not the same!
Discord is a video game chat service while Discourse is forum software.
There are two main steps to setting up a Discourse server. 1, create a cloud server with one of the popular providers like DigitalOcean.
Then, install Discourse, start it, and complete the setup.
When you set up a Discourse forum community, the Discourse software offers you multiple ways to control assess to resources. One of such ways is by creating Discourse groups.
When you create a Discourse group, you can determine Discourse users that own the group and determine users that belong to the group.
Not only that, but you can also set permissions on the group and configure other additional settings.
My Final Thoughts About Configuring StackPath CDN for Discourse Forum

The Discourse forum software comes with inbuilt support for CDN. However, as of when I configured Itechguides Community in June 2022, there was no step-by-step guide.
After some research, I decided to StackPath CDN for our Discourse. In the process, I decided to document the steps so that other people could benefit from them.
I hope that you were able to configure CDN for your Discourse forum with StackPath by following this guide. If you found the guide helpful, kindly spare me 2 minutes to provide feedback.
To share your feedback, reply to this article’s topic at Itechguides Community.
Finally, to read more articles about WordPress and websites, visit our WordPress & Websites How-Tos page.
To ask a question or comment about this article, visit the article's topic at Itechguides Community