Enable a CDN for your Discourse


(Sam Saffron) #59

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

(Arta) #60

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

(Sam Saffron) #61

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

(Arta) #62

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

(Sam Saffron) #63

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


@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

(Jeff Atwood) #66

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).

(Drew Friestedt) #67

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.

(Jeff Atwood) #68

The cdn would be at its own name like


(Drew Friestedt) #69

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.

(Jeff Atwood) #70

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?

(Drew Friestedt) #71

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.

(Jeff Atwood) #72

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:

(Anil Gupta) #73

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:

(Alex) #75

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

(Jeff Atwood) #76

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

Using Cloudflare Discourse IP works but not the url
(Alex) #77

Well why wouldn’t you recommend Cloudflare for Discourse?

(Jeff Atwood) #78

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