SSL/TLS, Origin Certificates and 502 Bad Gateway

Hi,

When not proxied the certificate is not trusted by the browser. (issued by Cloudflare)

When proxied the certificate is trusted, it says issued by Letsencrypt, but I get the 502 error, Bad gateway, Please try again in a few minutes.