You seem to be using Cloudflare’s proxy service, so:
The redirect loop is happing due to a (imho) fairly insecure default called “Flexible SSL”, which sets how Cloudflare decides to connect to your upstream server.
See this very extensive post from 2018, which still applies to this date
But feel free to ask any further questions if you have any