Cloudflare 521-fout na upgrade naar 3.5.0.beta8-dev

AI-generated summary

After upgrading to Discourse 3.5.0.beta8-dev, LW2333 began experiencing Cloudflare 521 errors (“Web server is down”) when using Full (Strict) SSL mode, though switching to Flexible mode temporarily resolved the issue. They confirmed using a Cloudflare Origin Certificate (not Let’s Encrypt), stored in /var/discourse/shared/standalone/ssl/, and rebuilt the app after verifying the config. LotusJeff reported no issues on the same version with Full (Strict) and suggested checking Let’s Encrypt setup or firewall rules, noting that 521 often indicates the server isn’t properly configured for HTTPS. LW2333 clarified they’re not using Let’s Encrypt and shared their app.yml config, which includes cloudflare.template.yml and web.ssl.template.yml. LotusJeff reminded them that Cloudflare certs typically expire every 90 days (though LW2333 confirmed theirs are valid for 15 years and tried regenerating them without success). LW2333 then asked if switching to Let’s Encrypt would resolve the issue, to which LotusJeff advised uncommenting both the Let’s Encrypt template and setting LETSENCRYPT_ACCOUNT_EMAIL in app.yml, while cautioning that manual SSL customizations must be reverted. They also recommended monitoring the rebuild process for Let’s Encrypt errors.

Hi everyone,

After updating my Discourse site to 3.5.0.beta8-dev, I’m suddenly getting a 521 “Web server is down” error when accessing the site through Cloudflare. This is unexpected since I had previously configured it according to this guide, and it had been working perfectly until now.

Then I tried changing the SSL/TLS encryption mode in Cloudflare from Full (Strict) to Flexible, and the site loaded again.

Does anyone know why this might be happening after the update?
Is there something new in 3.5.0.beta8-dev that could affect Cloudflare compatibility or HTTPS handling?

Any help or suggestions would be greatly appreciated!

Thanks in advance!

Ik draai 3.5.0.beta8-dev met Full (strict) SSL met Cloudflare en heb geen problemen.

Een paar dingen om te controleren:

  • Controleer uw Let’s Encrypt - Bekijk uw upgrade logboek en valideer dat alles correct is herbouwd.
  • Controleer op wijzigingen in externe firewalls (DigitalOcean biedt externe firewalls)

De 521 en de overgang naar Flexible geven aan dat uw server niet is ingesteld met HTTPS.

Thanks for the suggestions! @LotusJeff

I’ve checked my SSL setup, and I’m not using Let’s Encrypt, I generated an Origin Certificate from Cloudflare, and placed the key and cert here:

I did a full rebuild after checking. But I’m still getting a 521 error when Cloudflare is set to Full (Strict).

Here’s the template section from my app.yml for reference:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  # - "templates/web.letsencrypt.ssl.template.yml"
  - "templates/cloudflare.template.yml"

expose:
  - "80:80"   # http
  - "443:443" # https

Thanks again for taking the time to help!

Werkend vanuit het geheugen, hebben Cloudflare-certificaten een duur van 90 dagen. Dit vereist dat u elke 3 maanden nieuwe certificaten aanmaakt. Weet u nog hoe oud uw certificaten zijn?

De standaardinstelling is om Let’s Encrypt te gebruiken. Het systeem zal uw certificaten automatisch vernieuwen. Eén zorg minder om handmatig te beheren.

Cloudflare now privide Certificates that valid for up to 15 years, mine is still within the valid period.

That said, just to be sure, I also tried generating a new certificate and replaced the existing one, but I still got the same problem.

If I want to switch back to the default setup using Let’s Encrypt,
is it enough to simply:

  1. Uncomment this line in app.yml:
- "templates/web.letsencrypt.ssl.template.yml"
  1. And set Cloudflare’s SSL mode to Full?

Ik heb de overstap van privécertificaten naar Let’s Encrypt met Discourse nog nooit gemaakt, en met dat gezegd hebbende…

Binnen de app.yml moet je op twee locaties de commentaar verwijderen:

  1. Template regel voor - "templates/web.letsencrypt.ssl.template.yml"
  2. Het e-mailadres van het Let’s Encrypt-account:
## Als je de Let's Encrypt-template hebt toegevoegd, verwijder dan de commentaar hieronder om een gratis SSL-certificaat te krijgen
  LETSENCRYPT_ACCOUNT_EMAIL: <voeg hier je e-mailadres toe>

Als je andere handmatige wijzigingen hebt aangebracht in templates voor aangepaste SSL-certificaten, moeten deze worden teruggezet naar de standaardinstellingen.

De Let’s Encrypt-component bevindt zich aan het einde wanneer je de app opnieuw opbouwt. Houd deze in de gaten en kijk of je foutcodes ontvangt.