Finally the solution for this case was to modify the app code by doing the following changes:
app.UseHttpsRedirection();
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedProto,
});
Additionally, I performed some adjustments in apache server in the VirtualHost that handles requirements with port 80. This line was added:
Redirect permanent / "https://example.com/"
after those changes, the application was authenticated sucessfully against azure entra and the redirection was correct.