# Configuring Caddy and Cloudflare for Discourse

**URL:** https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563
**Category:** Support
**Created:** [February 11, 2025, 12:10am UTC](https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563 "2025-02-11T00:10:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![BrianC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/brianc/32/487568_2.png) [@BrianC](https://meta.discourse.org/u/BrianC)
#### Post date: [February 11, 2025, 12:10am UTC](https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563/1 "2025-02-11T00:10:45Z")

</div>

Hello everyone,

I’ve set up Discourse on [community.website.com](http://community.website.com) and WordPress on [website.com](http://website.com). I’m using Caddy as the reverse proxy with Let’s Encrypt managing SSL. After some initial hurdles, I got everything working smoothly, including SSL and redirects. I went with this setup after **numerous** failures of attempting other ways to get reverse proxy working. The underlying issue for me was no prior Docker or Discourse experience.

I also understand there can be issues with caching and Discourse so perhaps less is better or some rules to avoid problems.

**Current Setup:**

- **Discourse:** Running via Docker on [community.website.com](http://community.website.com).
- **WordPress:** Installed on [website.com](http://website.com).
- **Caddy:** Handles reverse proxy and Let’s Encrypt SSL.
- **Cloudflare:** Configuring for DNS, firewall, and CDN.

**The Challenge:**

When using **Cloudflare DNS without proxy** (just for DNS), everything works perfectly—Caddy manages Let’s Encrypt SSL, and there are no issues.

However, when switching to **Cloudflare DNS with proxy enabled** , the connection fails with a **“Website Down” error from Cloudflare**. I’ve updated my Caddyfile to use http:// for both root and subdomains and tried multiple SSL configurations in Cloudflare (Flexible, Full, and Full Strict), but I haven’t been able to establish a connection.

The question is how should I configure this so Caddy, Cloudflare with SSL plays nice with Discourse?

Any suggestions are appreciated!

---

<div class="post-metadata">

### Author: ![qingfeng1024](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/qingfeng1024/32/495412_2.png) [@qingfeng1024](https://meta.discourse.org/u/qingfeng1024)
#### Post date: [February 11, 2025, 1:14am UTC](https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563/2 "2025-02-11T01:14:31Z")

</div>

If you’re utilizing Cloudflare’s CDN and security services, you don’t need to configure your own SSL certificate on your origin server. Instead, navigate to the SSL/TLS settings within your Cloudflare dashboard and create an ‘Origin Certificate’. This certificate will secure the traffic proxied from your origin server to Cloudflare. Install this Origin Certificate on your origin server, and everything will be operational

---

<div class="post-metadata">

### Author: ![JamesNorth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesnorth/32/283740_2.png) [@JamesNorth](https://meta.discourse.org/u/JamesNorth)
#### Post date: [February 11, 2025, 1:28am UTC](https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563/3 "2025-02-11T01:28:07Z")

</div>

Are you running Caddy and Wordpress on the host machine or as Docker containers?

---

<div class="post-metadata">

### Author: ![BrianC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/brianc/32/487568_2.png) [@BrianC](https://meta.discourse.org/u/BrianC)
#### Post date: [February 11, 2025, 11:16pm UTC](https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563/4 "2025-02-11T23:16:13Z")

</div>

Thank you @shannon1024 ! First time for that one but nice and smooth and working now.

---

<div class="post-metadata">

### Author: ![BrianC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/brianc/32/487568_2.png) [@BrianC](https://meta.discourse.org/u/BrianC)
#### Post date: [February 11, 2025, 11:17pm UTC](https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563/5 "2025-02-11T23:17:14Z")

</div>

Running on Docker. Made a directory in the Discourse directory for the certs. I was surprised in work on first shot 😄

---

<div class="post-metadata">

### Author: ![agemo](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@agemo](https://meta.discourse.org/u/agemo)
#### Post date: [June 18, 2025, 2:01pm UTC](https://meta.discourse.org/t/configuring-caddy-and-cloudflare-for-discourse/351563/6 "2025-06-18T14:01:09Z")

</div>

> **Step 5: Configure Discourse to Use the SSL Certificate**
> 
> 1. Edit the Discourse NGINX configuration to use the SSL certificate. Typically, this file is located at `/etc/nginx/conf.d/discourse.conf` or within the `/var/discourse/containers/` directory if using Docker.
> 
> 2. Modify or add the following lines to the server block:
> 
> [https://developer.tenten.co/discourse-with-cloudflare-ssl](https://developer.tenten.co/discourse-with-cloudflare-ssl)

I am trying to setup CF origin server and I am stuck at this stage for the location of the `discourse.conf` file so I can make the necessary modifications, where is this normally?

The instructions are not totally right here afaict because I found nothing in these locations.

Thanks for any assistance in advance.
