Configuring Caddy and Cloudflare for Discourse

Hello everyone,

I’ve set up Discourse on community.website.com and WordPress on 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.
  • WordPress: Installed on 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!

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

1 Like

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

1 Like

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

1 Like

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

1 Like