May I ask did you checked any of the suggestion in the below article regarding the 522 error? Regarding Cloudflare 522 error, may I suggest you to try looking into below articles to troubleshoot the issue:
Before moving to Cloudflare, was your Website working over HTTPS connection?
You could determine this by:
Use the “Pause Cloudflare on Site” option from the Overview tab for your domain at dash.cloudflare.com .
The link is in the lower right corner of that page.
Give it five minutes to take effect, then make sure site is working as expected with HTTPS.
Renew your SSL certificate using cPanel / AutoSSL / Certbot / Let’s Encrypt / Contact your web hosting provider.
Only then should you un-pause Cloudflare and double-check your SSL/TLS setting to make sure it’s Full (Strict).
May I ask what SSL option have you got selected under the SSL/TLS tab at Cloudflare dashboard for your domain ( Flexible, Full, Full Strict … )?
Here is a way to re-check if you correctly setup the SSL for your domain with Cloudflare:
In case you do not have an SSL certificate, you can use Cloudflare SSL, if so, kindly make sure you follow the instructions as follows on the below article to setup an SSL certificate using Cloudflare Origin CA Certificate: