# Discourse and cloudflare

**URL:** https://meta.discourse.org/t/discourse-and-cloudflare/133366
**Category:** Self-hosting
**Created:** [November 14, 2019, 5:06am UTC](https://meta.discourse.org/t/discourse-and-cloudflare/133366 "2019-11-14T05:06:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![chi\_noti\_info](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@chi\_noti\_info](https://meta.discourse.org/u/chi_noti_info)
#### Post date: [November 14, 2019, 5:06am UTC](https://meta.discourse.org/t/discourse-and-cloudflare/133366/1 "2019-11-14T05:06:12Z")

</div>

Hello.

I was reading some of the guides about cloudflare and discourse and didn’t quite get anything strightforward out of it. Some say discourse and cloudflare don’t work well together, others say they do, some say there have to be some tweaking in app.yml (some additional subdomain), others say it works just fine without that.

IN my experience, discourse seems to work fine without the tweaking (which I feared doing because i didn’t quite understand it and i feared the guide might be outdated).

On the other side an user here, when asked about how to enhance security, recommended me to “put discourse behind Cloudflare with a page rule to “disable performance” so that it doesn’t screw around with the code.”. What should that rule look like? I have no idea.

As you can see i need some help with this.

TY in advance.

---

<div class="post-metadata">

### Author: ![Remah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/remah/32/70590_2.png) [@Remah](https://meta.discourse.org/u/Remah)
#### Post date: [November 14, 2019, 8:07am UTC](https://meta.discourse.org/t/discourse-and-cloudflare/133366/2 "2019-11-14T08:07:49Z")

</div>

All posts are not created equal so have you looked at the official how-to for admins:

> [@Full site CDN acceleration for Discourse](https://meta.discourse.org/t/full-site-cdn-acceleration-for-discourse/21467):
>
> [Fastly](http://www.fastly.com/) , [CloudFlare](https://www.cloudflare.com) and a few other CDNs offer a mode where they accelerate dynamic content. In a nutshell you point your domain IP address at the CDN and the CDN will intelligently decide how to deal with the request. Static content can be easily served from cache Dynamic content can be routed to the site. This provides some advantages over only shipping static assets which is covered in [the CDN howto](https://meta.discourse.org/t/enable-a-cdn-for-your-discourse/14857). You can elect for “[shielding](http://www.fastly.com/products/origin-shield/)” that protects your site from traffic spikes. Dynamic cont…

I don’t use Cloudflare but I understand that you should disable Cloudflare’s speed/performance optimizations for JavaScript, CSS and HTML. It is particularly important to disable Rocket Loader:

[https://support.cloudflare.com/hc/en-us/articles/200168206-How-do-I-access-my-Cloudflare-Performance-Settings-](https://support.cloudflare.com/hc/en-us/articles/200168206-How-do-I-access-my-Cloudflare-Performance-Settings-)

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [November 14, 2019, 8:13am UTC](https://meta.discourse.org/t/discourse-and-cloudflare/133366/3 "2019-11-14T08:13:07Z")

</div>

We use Cloudflare with Discourse, but there are some things to watch out for. Here’s our setup:

> [@S3 image bandwidth costs are getting annoying](https://meta.discourse.org/t/s3-image-bandwidth-costs-are-getting-annoying/122052/4):
>
> I’m using Cloudflare on [my Discourse site](https://blenderartists.org) and it works fine. You basically route all your traffic through Cloudflare and tell it what to process or cache and that’s it. There are a few things to keep in mind though: Configure Cloudflare to NOT cache anything (set up exceptions using page rules, see below). Don’t let Cloudflare touch your Javascript - specifically, turn off Rocket Loader. I’m not sure about Brotli compression yet, I disabled it. Set up page rules to cache the avatar and upload …

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 9, 2023, 11:53am UTC](https://meta.discourse.org/t/discourse-and-cloudflare/133366/4 "2023-08-09T11:53:25Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [August 9, 2023, 12:33pm UTC](https://meta.discourse.org/t/discourse-and-cloudflare/133366/5 "2023-08-09T12:33:29Z")

</div>


