If you unproxy you cannot experience 524s as requests won’t be going through Cloudflare. Only thing, you might be still going through the proxies because of DNS propagation. You’d just need to wait in that case.
As for the 524 itself, you need to make sure your server responds within 100 seconds. More at Community Tip - Fixing Error 524: A timeout occurred.