I have hosted an Angular SSR (NodeJs) application in my IIS (Windows VPS).
It is working if Cloudflare Proxy is turned off. But if Cloudflare Proxy is turned on it shows the 502 error, please find the attached screenshot for the same.
The 502/504 errors are caused by a problem connecting to an upstream server - meaning your server is trying to initiate a process and this fails to work as expected or times out. In most cases of 502 / 504 errors, back-end servers are not communicating correctly. When this happens, you will see color page with Cloudflare branding and the Error 502 Bad Gateway or Error 504 Gateway Timeout. Review this Community Tip for fixing 502 or 504 gateway errors.
I have found the root cause for this. If I enable Full or Full (strict) SSL modes in Cloudflare. I’m getting a 502 error. But my server has already been configured with the Let’s Encrypt certificate.