Keycloak Docker HTTPS required Keycloak Docker HTTPS required docker docker

Keycloak Docker HTTPS required


Publish port 8443 (HTTPS) and use it instead of 8080 (HTTP):

docker run \  --name keycloak \  -e KEYCLOAK_USER=myadmin \  -e KEYCLOAK_PASSWORD=mypassword \  -p 8443:8443 \  jboss/keycloak

Keycloak generates self signed cert for https in this setup. Of course, this is not a production setup.


Update

Use volumes for own TLS certificate:

  -v /<path>/tls.crt:/etc/x509/https/tls.crt \  -v /<path>/tls.key:/etc/x509/https/tls.key \


This was a solution that also granted access to the admin console with no security when using https://hub.docker.com/r/jboss/keycloak/ as a starting point and DigitalOcean as service provider:

Start container:

$ docker run {containerName}

Open bash for container:

$ docker exec -it {containerName} bash

Move to:

$ cd keycloak/bin

create new admin user with:

$ ./add-user-keycloak.sh --server http://{IP}:8080/admin    --realm master --user admin --password newpassword

(not add-user.sh as suggested in many places)

Restart droplet in DigitalOcean etc. to activated admin user created prior to the shutdown. After restarting the droplet login with:

$ ./kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin

Changing ssl settings on the realm:

$ ./kcadm.sh update realms/master -s sslRequired=NONE

This solution does not create any security but allows you to access the Admin console.

After this it is suggested to start workin on this:https://www.keycloak.org/docs/latest/server_installation/index.html#setting-up-https-ssl


The following sequence of commands worked for me

On the host VM:

docker run --name key -d -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin jboss/keycloakdocker exec -it key bash

Inside the container:

cd keycloak/bin/./kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin Logging into http://localhost:8080/auth as user admin of realm masterEnter password: admin./kcadm.sh update realms/master -s sslRequired=NONE