Enable a CDN for your Discourse

hmm, can you resolve avatars from your host (or container)

Do you recommend MaxCDN? I am already their customer so it would be nice to keep things in a place.

Sure, we use them for some of our sites, reliable CDN

3 Likes

One question. if my discourse website uses SSL, then CDN must use SSL too right?

Yes, that is correct, most CDNs give you an ssl endpoint for free

7 Likes

@codinghorror - I see you recommend Fastly… that was a few years ago. This still the case now?

edit - also, they’ve overhauled their onboarding significantly to look like this:

view big image

Fastly is solid, you should shop around and see what prices and service you are interested in. The usual way all CDNs charge is per gigabyte per region (north america, europe, etc).

3 Likes

I’m trying to setup Fastly for my CDN.

Here is my setup:

Domain: discuss.endurancelab.fit
Address: IP Address of Host at Amazon
SNI Hostname: discuss.endurancelab.fit
TLS CA: I’m using Let’s Encrypt (installed at setup)

Fastly accepts all the settings and instructs me to add a CNAME. Adding CNAME records - Basic setup | Fastly Help Guides

At this point I’m a little confused. what DNS entry do I make? I can’t create a CNAME for discuss.endurancelab.fit to global.prod.fastly.net because of the MX and TXT entries on that domain.

The cdn would be at its own name like

discuss-cdn.endurancelab.fit

I thought traffic routes through fastly to the host? So don’t I need to point the domain name discuss.endurancelab.fit to global.prod.fastly.net which then routes traffic to the IP address of the host?

Also, from the Fastly website: “When using free TLS, you cannot DNS alias your own domain (www.example.org) to the shared domain (example.global.ssl.fastly.net). If you do, a TLS name mismatch warning will appear in the browser. The only way to avoid the mismatch error is to order a paid TLS option.”

Sorry, I’m sure this is a stupid question but I’ve literally spent about 4 hours reading the fastly docs and I’m stuck.

1 Like

I don’t recommend routing all your traffic through there, ala Cloudflare. I am describing a traditional CDN, where only the static assets (css, js, etc) are delivered via CDN nodes close geographically to the user.

Does fastly no longer offer traditional CDN services?

Yes - they do deliver traditional CDN. I was hoping to test out dynamic content acceleration. But if you don’t recommend that, I won’t try it.

1 Like

It is a way more complex setup for arguably negative benefit. We are a JavaScript app not a set of 1996 era old school HTML web pages :wink:

9 Likes

We have deployed Discourse on Google Compute Engine and looking to use Google Cloud CDN via Google Cloud Load balancer.
The load balancer automatically caches content (or any file) that has the cache-control header set. There are no separate origins needed.

  1. Is there a way we can set the cache-control headers for static assets?
  2. Do we have any example where someone would have achieved caching with Google Load Balancer?

I would appreciate any help here.

Update: 30 Dec 2017.
I found out that my discourse install is actually setting the ‘Cache-control’ header automatically for static assets like images and JS files. This certainly helps me use the Google CDN with no changes what-so-ever. Wow :slight_smile:

Earlier, i was not able to see it because we were running the ‘Bitnami Discourse image’. I think their image carries the development version of Discourse and hence, the headers are NOT set automatically.

I am happy that I moved to Official install!
Thanks guys.

Our Discourse installation:

7 Likes

I see Discourse recommends Fastly, but what about Cloudflare CDN? That is arguably the best CDN in the world.

Cloudflare isn’t a traditional CDN, more like a global man-in-the-middle service.

1 Like

Well why wouldn’t you recommend Cloudflare for Discourse?

Do a search and see for yourself https://meta.discourse.org/search?q=cloudflare%20broken

2 Likes

Hi,

Sorry but i do not understand that;

How does discourse send new files ( images, updated js etc ) to my cdn provider - for aws cloudfront , how to s3 bucket which i used for cloudfront.

thanks

1 Like

Your CDN requests them if it is asked for them and hasn’t yet cached them.

If you configure any CDN, that’s how they work. Bunny.net is easy to configure.

4 Likes