Cloudflare setup and other post-migration tasks

Hey there, I’ve been working with some other people to finish an ad-hoc migration of our old vbulletin3 to discourse. Now it’s time to start thinking about some other aspect for the migration, one of which is the fact that we have a cloudflare account that serves our forum.

We would like to keep it if possible as our forum has tons of lurkers (and around 1000 active users).

The only thread I’ve found here that is somewhat having some info e’ from 2015 so I’m asking if there is any “official” doc that I might have missed that specify how to set up cloudflare with discourse properly.

Secondarily I’d like to know if there is a process to follow to:

  • have discourse update stats post migration
  • have discourse search index “refresh” post migration

Thank you in advance :slight_smile:

Serves how? It’s easiest to just use dns mode. If you want to spend some extra time for very little benefit, there are some topics about that. Mostly, you disable the optimizations that break discourse. If what you want is to take some load off of your server, then a real cdn like bunny.net is the way to go.

I think that the stats and search should just work.

It might be a little short-sighted to imply that Cloudflare is not a “real CDN” ? Because it is (and more than that). Maybe you meant “traditional” CDN ?

Setting up a traditional CDN will cost a lot more time and get you about the same amount of benefit.

1 Like

Fair enough!

And cloudflare may be cheaper, as the free version is likely enough for lots of people. It seems that there is always an active topic where someone has broken their site with cloudflare, and the easiest way to make it work, seems to be to turn off all optimization so that it can only increase latency.

If you were to create a topic that describes how to configure cloudflare such that it provides the same benefit as a traditional cdn it might be very helpful indeed. Perhaps it’s as simple as disabling the rocket loader, but it seems like exactly how to set it up might be a moving target (as they change and improve their product).

I’m sorry I don’t want to cause a discussion about which CDN is best etc.

I’ve yet to get more info myself but as far as I understand, the forum currently use a paid plan (so not the free option I guess) but even so, it’s beyond the point.

Simple question :slight_smile: → What do I need to do to set cloudflare up so it doesn’t bother discourse?

After that I’m more than happy to understand if it’s even something really needed or not (meaning, benefits etc) :slight_smile:
Also, if someone can give me a link or something about the other two minor questions, that would be great :heart:

I’m going to use next week to run some test in a staging environment so nothing is set in stone!

If you are hosted by discourse.org , or anyone else, for that matter. You should check with them before doing anything with cloudflare. Typically you just create a DNS CNAME that points to their servers. Discourse.org already has CDNs in place, so you don’t need to worry.

Thanks @pfaffman, it’s self hosted. As I said it’s used for the current vbulletin forum that will simply go offline and be replaced by discourse which will respond from the same domain name.

1 Like

It depends on what role (if any) you want Cloudflare to play.

If you just want to use Cloudflare as DNS then make sure the orange cloud is disabled for the ‘a’ record of the forum.

If you want to actually send Discourse traffic across Cloudflare’s network and are ok with the additional latency it adds then at the minimum create a page rule to ‘Disable Performance’ for the entire forum domain. None of the Cloudflare performance optimizations are recommended and have been known to break sites.

Note that there’s a Cloudflare template which needs to be added to your app.yml, it will pass the CF-Connecting-IP as the client IP, so that you aren’t seeing everyone as originating from a node on their network.

If you aren’t using object-based storage and do run with the orange cloud enabled you can create a caching rule for your assets path.

2 Likes

Thank you @Stephen.

Cloudflare was (well, still is for now) used to not overload the actual webserver with requests.

I was wondering most of all, with Discourse nature of real time updates (I’m assuming websocket? didn’t check) how that could be a problem with something like cloudflare caching and all that. That’s why I was wondering if there was any docs or anyone had any tips :slight_smile:

I don’t know anything and that’s why I’m so lost every now and then, but it sounds like you are looking for the nature of PHP but you get the nature of JavaScript app where everything except getting actual data is happening in users’s device.

That is the reason (and my limited skills) why my attemps to put Varnish front of Discourse failed so miserably.

Sure, you can serve assets from CDN but that’s it.

1 Like

Right, Cloudflare isn’t able to do anything to reduce application server load. As a single page javascript app, Discourse really doesn’t benefit.

It gets worse though, because putting Discourse behind Cloudflare adds network hops for every requests between the app in browser and server, so there’s a slight increase in response times.

Are you keeping uploads on the server, or using S3/an s3-like alternative?

1 Like

Sorry for the delay in replies.

I don’t know enough about Discourse design but thinking about the presence of redis already manage some caching of common requests. That explain the “cloudflare not being really needed”

So, am I understanding it right as basically there is little to no benefit in having Cloudflare in front of a Discourse installation, and on the contrary, it would slow down response instead (network hops)?

The only reason for cloudflare for the vbulletin3 installation was that the amount of request would overwhelm the server and (just assuming here) could be because of the poor work in the code design of vbulletin3 to be honest because the VM that host it is a 4vcore, 8gb ram just for the application itself and another VM of equal specs for the DB.

There is no way any modern web-app need that much power today.

Speaking of, is there any reference I can consult to evaluate how much hw I would need for a discourse installation that on average have ~1K active users and ~5-6K lurkers?

That is not completely true. Especially on a first load, Cloudflare can speed up the Javascript static asset loading. And that is exactly one of the things that Google looks at to decide if your site is performant enough to avoid a search engine penalty. The benefits are larger when you have a marketing kind of forum that attracts users from search engines, and the downsides are larger when you have a forum with an active, returning, group of users.

No, because it really depends on whether those users are very active or whether they visit once a day. I’ve seen a group of < 50 people exchanging large photo’s and using discourse as a chat box for the entire day bring really performant hardware on its knees, while I have also seen a forum with 10,000 people that came by to post something once a week and over 30 million (!) lurkers run on a mediocre VPS.

2 Likes

Thanks for the insight and info @RGJ, I guess I’ll just monitor and we’ll see how things goes. Hopefully it’s not going to require a massive increase in requirements compared to the previous software :crossed_fingers: