You can use Cloudflare as DNS and a cache for /uploads, but if any of their caching or “optimisation” features are touching the page then you’re completely unsupported here.
There are a long list of Cloudflare tweaks which break discourse in new and interesting ways.
Either way Cloudflare is a tangent, as indicated above the error being discussed is very likely due to nginx not receiving origin IPs. Let’s deal with the root cause rather than slap a bandage on a symptom.