Infinite redirect loop in ASP.NET core while enforcing SSL

In my case, reverse proxy was on a separate server, so, my asp.net core app was not accepting this proxy because the proxy is no on ForwardedHeadersOptions.KnownProxies and the network is not in ForwardedHeadersOptions.KnownNetworks I apply this solution and the inifite loop dissapear:

services.Configure<ForwardedHeadersOptions>(options =>
        {
            options.ForwardedHeaders =
                ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
            options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::ffff:100.64.0.0"), 106));
        });

You can also use options.KnownProxies and add the ip address of your reverse proxy, In my case I did not add because the reverse proxy is dynamic.

Pay attention to ::ffff: you need to put this prefix, this is IPv4MappedToIPv6 address more information on https://github.com/aspnet/Docs/issues/2384#issuecomment-387875157

Thanks