Keycloak redirects with port number appended to host

Im using Keycloak (24.0.1) on kubernetes on GKE platform. I have used GKE ingress to welcome traffic and routed the traffic through nginx service to remove the unwanted URLs being exposed such as /admin.

Below are my configurations

KC_PROXY_HEADERS="xforwarded"
KC_HTTP_ENABLED="true"
KC_HOSTNAME_STRICT="false"

And i Below is my nginx configuration

location / {
    
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-Host $host;
  
    proxy_pass http://keycloak.backend.svc.cluster.local;
}

When i try to login from my webapp via keycloak it redirect me to the correct URL but with port number attached to host. like

https://keycloak.mydomain.com:80/realms/master

Any help to fix above is welcome. Thanks

1 Like

Hey bro, did you get any solution for this?

Yep, set the frontend url to your desired URL from keycloak UI

1 Like