Discourse & Cloudflare

The CloudFlare template isn’t a new addition, and if you take the time to look at the source you will see that the sole purpose is grab their IP ranges and modify nginx to ensure it’s looking at the CF-Connecting-IP as the true client address is obscured by the proxying the orange cloud provides. It’s not a new thing, it’s been around for at least seven years. You can use Cloudflare to conceal the whereabouts of your server, or act as a cheap CDN for uploads, but in both cases we would recommend you disable all performance features and use a page rule to enable caching on your uploads folder.

Right, my point was that if Cloudflare was unsupported, they wouldn’t bother officially adding in any kind of support for it the first place. They also wouldn’t have official tutorials on how to use it. Granted, they may recommend not using it because of X, Y, and Z in some cases, but that’s not the same as something being flat-out unsupported. :skull_and_crossbones:

What benefit would testing via GTMetrix demonstrate? I think you have a fundamental misunderstanding of how Discourse works to be citing that. Discourse isn’t a website, it’s a Javascript application. Navigating the site doesn’t serve flat HTML pages to the browser. The Javascript app which loads into your browser talks to the server directly, which is why certain page elements don’t appear to reload between clicks. The snappiness of said application is only determined by server resources and latency between client and server. CloudFlare can’t speed up your Discourse instance, and its presence between the two systems increases latency.

Yes, I understand that Discourse isn’t a website. It’s a platform for delivering content like any other platform/software/CMS. Of course Cloudflare can’t impact anything at the server-level, which is especially true of LAMP setups. But, ultimately, every platform has to eventually deliver all the client-side code (HTML/CSS/JS). Of course GTmetrix can’t scan for server-side speed, but you can still glean some things about the final output of your setup. In other words, how the user experiences the loading of content.

Cloudflare doesn’t actually speed up a website all that much, not nearly as dramatically as server-side optimizations and better server resources do. We’re in full agreement on that. Its main focus is optimizing DNS. There’s some more advanced CDN features for paid accounts, especially where images are concerned, but I’ve never even used a paid account. I wonder if it’s some of those advanced features where people run into the most trouble and have to ask for help?

The above is based on years of experience, not a feeling. Discourse still has periodic problems with Cloudflare. Beyond obscuring your server IP and saving a little data transfer for uploads there’s nothing that Cloudflare can do to speed up a Discourse site.

Dang it. I knew I was going to get grief for saying “feeling,” but it’s just a figure of speech. I’m talking from experience too. :stuck_out_tongue_closed_eyes:

I wouldn’t challenge the fact that as a Leader in the official Discourse community, you obviously have more experience with Discourse, and clearly have seen all kinds of wacky issues caused by Cloudflare.

Aside from getting into the weeds about all the nuances of Cloudflare/Discourse, I still stand by my primary point though, which is merely that Cloudflare isn’t at all as scary as the narrative in this forum would have most people believe.

That said, I also understand managing communities and obviously not everyone is a developer or even tech-savvy. In that sense, I can see why being flooded with people thinking that Discourse is broken when it’s just Cloudflare or something similar would become annoying.


That’s the point. “unsupported” doesn’t mean “impossible”, but “good luck with that”. One frequent answer to “there is a bug” is “does it go away if you turn off cloudflare”?

If you do want to speed things up use a real CDN - - Enable a CDN for your Discourse


Or, ya know, if someone wants a completely free option or they otherwise just want to use Cloudflare, they can, no problem.

You’re citing a recommendation from nearly a decade ago. Things change. I would really like to see one of the official devs weigh in on this in 2022. I’m guessing he would say that things are much more stable, and also, any recommendation about not funking with JS is probably the recommendation for all CDNs, not just Cloudflare.

Please don’t tag team members, if they want to weigh in they will.



I tagged the creator of Discourse. We can go back and forth all day about where Discourse stands in 2022 concerning Cloudflare, but until we hear it from the horse’s mouth, it’s more speculation than a definitive answer.

How would he possibly even know that anyone’s asking for his thoughts in order for him to weigh in unless he’s tagged?

There was an issue just last week that had to do with people seeing ads when they shouldn’t that it was pretty clear was an issue with cloudflare. Turning it off is always one of the first things to do. Lots of people getting support here are complete novices and making things as trouble free as possible is the goal. If it works for you, that’s great. If you want to respond to twenty or more posts a week that

But that’s not true. If you use a real cdn discourse users it only for the stuff that should be served by cdn.

Hey @JammyDodger, I think it’s time for a cloudflare faq (though it’s not the first time I suggested it). You can get Jeff and Sam to weigh in.


Here’s the thing. Caching/combining/minification notoriously breaks JS, regardless of the software or CDN combo being used. I’ve seen this common issue with a dozen other tools/services. When dealing with novices, their browser cache alone is a constant pain to educate them about. I’ve managed large software communities before; I’m well aware of the same old issue coming up again and again.

What I’m wondering is, is this really a Cloudflare problem specifically OR is this a common problem that all optimization tools have where they can break JS and it just so happens that because of the popularity of Cloudflare, this general problem is mistakenly conflated as a Cloudflare problem. Does that distinction make sense?

In any case, yes, I would love for the official devs to weigh in on this and a current FAQ would be very helpful. I’m getting a lot of push back, but I’m not trying to cause problems. It’s just frustrating that the community is full of so many contradictions on this; I’m just trying to get to the bottom of where things truly stand in 2022.

But, if I can’t, if we can’t, that’s okay. Enjoy the rest of your weekend everyone. I’ll leave the poor :horse: alone now.


No, that is not true. We see issues with Cloudflare in combination with Discourse on a very frequent basis.

There is no such thing as “supported”. But if you don’t know what you’re doing, it can and will cause issues, and even you do know what you’re doing you can get unexpected problems.

The performance benefits of Cloudflare, if any, will be small. Most assets served by Discourse are well-compressed and immutable (i.e. they’re cached by the browser for a very long time). Most other content is non-cachable because it’s personalized application data.

That said, Cloudflare can be very useful for DDoS protection.


That would be welcomed since we have mixed opinions from different users :person_shrugging:

1 Like

We’ve got a FAQ for Cloudflare and how to (not) configure it for Discourse. It applies to self-hosted instances as well.


I don’t doubt this, but I think you missed the distinction I was trying to get to the bottom of. Is it actually, specifically Cloudflare that’s the problem, or is it really just the fact that optimization tools of this nature can easily break JS in general? And most people just happen to use Cloudflare because of its popularity, creating a false conflation.

It would be like blaming Gmail or GoDaddy for issues that are inherent to all email or hosting services.

And if there were another CDN that was more popular than Cloudflare, you’d see just as many strange support requests about that service too.

Even if you don’t agree, do you understand what I mean?


Since we must avoid certain settings, and meta users said things like

All CloudFlare can do for you is hide your IP and act as a CDN for your uploads. The benefits are minimal


The performance benefits of Cloudflare, if any, will be small.

Is there a definitive and straightforward answer to the question “With no speed settings enabled, does Cloudflare have any benefit compared to Bunny CDN or Stackpath (or any “regular” CDN I suppose)”?

I’m still hesitating between Bunny which would decrease a lot my current CDN (Stackpath) costs, and Cloudflare, which in my case would be free (the domain’s owner can add my forum to his enterprise account).

Also, stuff I don’t understand because I’m not tech-savvy.


It’s not just about breaking JS. It’s also about proxying and making port 80 inaccessible, breaking LetsEncrypt, and some of these services caching more than they should.

Since Cloudflare is the biggest of these “optimization tools of this nature”, and it’s widespread, popular and free, it’s the one that most discussions are centering around. But yeah, you’re right. It’s a problem of tools like this in general.

So, yes, agreed.

Topics like these tend to be a bit dangerous in nature since people (especially in the “problem” target group) don’t tend to read very well. It’s like posting in a topic about the dangers of drug or alcohol abuse and claiming “no guys, it’s not just a problem of drugs and alcohol, I use drugs without any issue, and don’t forget people: overusing any substance is dangerous”. (Yes, I know. Every metaphor goes only so far, but it’s the best I could think of).

And we can say how dangerous things are as loudly as we want, but people will use it anyway.
That’s why we made a FAQ :wink:


A new FAQ guide sounds like a great idea. The Communiteq link was not very robust.

Here on this forum, some people are making general rules Cache Level: Bypass, Disable Performance, however, they are allowing Cloudflare to cache images or css. I haven’t seen an official response if that is a yay or nay…

Instead of saying don’t use Cloudflare, and then field problem children, perhaps it would be good to come forward with what should and should not be done. Then a quick link reference to that post in the future will answer those questions.

Just one man’s opinion.

@RGJ — Thank you! Many people may not see nor understand the point of my distinction or what difference it makes, but it brings a great deal of clarity to me. I get very frustrated without clarity, because without that initial, solid foundation, I then don’t know what path to go down to further focus on and gain better understanding of a particular subject.

1 Like

If you have any specific comments, I’d love to hear them.

With respect to caching, I’d say it’s a not a “yay” or “nay” but more like a “meh”:

1 Like


(We need an option to react/like part of a post; how to do it, I don’t have a clue — but then there wouldn’t be reason to write nill-posts like this… :wink: )

You specifically mention performance. In my quote, I specifically mention bandwidth saving. These are two different things, and different people will weight them differently.

Hey Richard, the Communiteq link was vague. The message, essentially don’t use Cloudflare.

Instead, why not say, if you use Cloudflare, use these settings? Spell it out. I think that’s what oopsyscoops is after as well. Some standard besides, don’t use it. If you turn off performance and allow caching of images, it seems that would be okay. I’m not the pro here though, so that’s why I’m asking. I just like knowing both sides of the issue here.

You said caching is meh? If that were true, then why bother with a CDN at all. They cache/store your files in remote locations so users can download them faster from their region. Not to mention, origin bandwidth and server load savings.

That’s the advice given by those who manage discourse for their living.

Because that seems to change from time to time. I’m constantly fighting to maintain instructions that help people make mailgun works, for example.

Cloudflare doesn’t work like a cdn. It’s something different. If you use a cdn, then discourse uses the CDN for things that should be cached. It doesn’t leave the CDN to guess how to work.

Unless you run a community that is likely to be the target of ddos attacks, cloudflare isn’t a good idea.

I’ve used bunny.net with a bunch of sites and it’s cheap and easy, though not free.