Secure Your Discourse Forum with Free SSL/HTTPS from CloudFlare

To use Cloudflare SSL instead of Let's Encrypt for your Discourse installation, follow these steps. Note that this process assumes you have already set up your Discourse server and have access to both your Cloudflare and server admin panels.
Step 1: Setup Cloudflare for Your Domain
Ensure your domain is added to Cloudflare. Change your domain’s DNS settings to point to Cloudflare’s nameservers. This update is made at your domain registrar’s site.
Step 2: Configure DNS Records in Cloudflare
Log into your Cloudflare account.
Select your domain.
Go to the DNS settings.
Add or confirm an A record pointing to your Discourse server’s IP address.
Step 3: Enable SSL/TLS encryption mode
In Cloudflare, go to the SSL/TLS tab.
Set the SSL/TLS encryption mode to "Full" or "Full (strict)". “Full (strict)” requires a valid SSL certificate on the server, which you can initially get from Let's Encrypt (to replace later).
Step 4: Install SSL Certificate on Your Discourse Server
Generate a Cloudflare Origin Certificate:
Go to SSL/TLS -> Origin Server.
Click "Create Certificate".
Choose “Let Cloudflare generate a private key and a CSR”.
Set the "Hostnames" to include your domain (e.g.,
example.comand*.example.com).Select the validity period (up to 15 years).
Click "Next" and copy both the Origin Certificate and Private Key.
Access your Discourse server via SSH.
Save the certificate and key to files on the server (e.g.,
/etc/ssl/certs/cloudflare_origin.pemand/etc/ssl/private/cloudflare_origin.key).
Step 5: Configure Discourse to Use the SSL Certificate
Edit the Discourse NGINX configuration to use the SSL certificate. Typically, this file is located at
/etc/nginx/conf.d/discourse.confor within the/var/discourse/containers/directory if using Docker.Modify or add the following lines to the server block:
ssl_certificate /etc/ssl/certs/cloudflare_origin.pem;
ssl_certificate_key /etc/ssl/private/cloudflare_origin.key;
- Restart NGINX to apply the changes:
sudo systemctl restart nginx
Step 6: Force HTTPS in Discourse
Edit the Discourse configuration file (
/var/discourse/containers/app.yml).Find the
envsection and add:
FORCE_HTTPS: 'true'
- Rebuild Discourse:
cd /var/discourse
./launcher rebuild app
This setup will enable your Discourse forum to use Cloudflare’s SSL, providing an added layer of security through Cloudflare’s services.
Hi All, Explore Cloudflare Consultant Tenten website for learn more or contact us for tech support.






