Redirection with AWS ALB

I’m configuring Keycloak under an ALB (Area Listed Building) and so far it’s been working correctly. The problem is that I have another service that connects to Keycloak through a namespace for internal communication.

This works correctly, but the problem is that when I log in, the service redirects me to the ALB using port 8080 instead of port 443.

The URL I’m configuring is http:///keycloak.demo:8080/realms/artisca/.well-known/openid-configuration

And it redirects me to https:///keycloak.mydomain.com:8080 (this isn’t the complete URL because it’s the redirect to the realm for logging in).

The correct URL would be https:///keycloak.mydomain.com without the port.

My configuration is:
ENV KC_HTTP_ENABLED=true
ENV KC_PROXY_HEADERS=xforwarded
ENV KC_HOSTNAME=https:///keycloak.mydomain.com

I don’t know if I’m missing something or if I need to change something. I’ve really racked my brain trying different things, but I can’t figure it out.

I’m not sure I 100% understand your question, but here are some suggestions:

  1. Check out the documentation on the use of the hostname parameter: Configuring the hostname (v2) - Keycloak
  2. Make sure you’re not actually using 3 backslashes /// as you posted
  3. Try KC_HOSTNAME=https://keycloak.mydomain.com and KC_HOSTNAME_BACKCHANNEL_DYNAMIC=true

Hello,
I probably didn’t explain myself very well. The communication between the services is internal and not through the DNS, hence my problems.

I tried setting KC_HOSTNAME_STRICT to false and it worked correctly.

Thank you very much.