keycloak redirects urls to http instead of https keycloak redirects urls to http instead of https nginx nginx

keycloak redirects urls to http instead of https


I was able to resolve this issue. We have dotnet core application and keycloak behing ssl terminating SSL proxy. Nginx setting as mentioned above is correct, the issue was application was not forwarding the headers properly to keyclaok. Following link helped:https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-2.1


    var forwardingOptions = new ForwardedHeadersOptions(){    ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto};forwardingOptions.KnownNetworks.Clear(); //its loopback by defaultforwardingOptions.KnownProxies.Clear();app.UseForwardedHeaders(forwardingOptions);

this code block from another answer solved the issue for me. .net Core X Forwarded Proto not working


With a nodejs/express app, I had to add the trust proxy setting.

app.set('trust proxy', function (ip) {  return true;  // if (ip === '127.0.0.1' || ip === '123.123.123.123') return true // trusted IPs  // else return false});