Getting 520 error with cloudflare active on `Fly io` server

I have my site on fly.io, I can access it correctly when cloudflare is disabled, however when I enable cloudflare, I get a 520 error, while I do that, I can access the server through the <subdomain> . fly . dev address, so It’s definitely something on Cloudflare. Don’t know what to do.

try to disable Automatic HTTPS Rewrites in Cloudflare.

Had the same issue, found this via google.

What helped me was SSL/TLS encryption mode to Full in the SSL/TLS settings and this totally makes sense, given that Fly takes care of the certificate stuff. https://elixirforum.com/t/deploying-a-phoenix-app-on-fly-io-with-dns-on-cloudflare/53557

You actually need Full Strict.