We do not support being proxy’d to (that is - you can do it, but we can’t help debug). The 502 error will be impossible for us to debug anyway, since it came from Cloudflare’s infrastructure. Perhaps their Support team has some insights, but we won’t ever have any…
You should probably check out this article for some more details on using Cloudflare in front of us - the SSL issue is not yours, but the rest of the caveats apply: [Support Guide] What problems could occur when using Cloudflare in front of Netlify?
We’ll be happy to help troubleshoot non-proxy’d-to functions of course, if you see the problem there!