docker keycloak启用ssl https
一、搭建一个外部的mysql
docker run --name mysql-kk -p 3308:3306 -e MYSQL_ROOT_PASSWORD=1234656 -d docker-local.repo.inspur.com/testserice/mysql/mysql-server:8.0.13
二、创建ssl证书
- mkdir -p /etc/nginx/cert/
- cd /etc/nginx/cert/
- openssl genrsa -des3 -out server.key 2048
- openssl req -new -key server.key -out server.csr
- openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
- mkdir -p /etc/nginx/cert/
- cp server.crt tls.crt
- cp server.key tls.key
(因为keycloak只识别tls这个名字所以要将名字改为tls.crt)
三、docker搭建keycloak
docker run --name keycloak -d \
-p 8443:8443 \
-p 8081:8080 \
-e KEYCLOAK_USER=admin \
-e KEYCLOAK_PASSWORD=admin \
-e DB_VENDOR=MYSQL \
-e DB_ADDR=xx.xx.xx.xx \
-e DB_DATABASE=keycloak \
-e DB_USER=root \
-e DB_PASSWORD=123456 \
-e JDBC_PARAMS='useSSL=false' \
-e TZ=Asia/Shanghai \
-e LANG=zh_CN.GB2312 \
-v /etc/localtime:/etc/localtime \
-v /etc/nginx/cert/:/etc/x509/https \
--privileged=true \
jboss/keycloak
https登录:
https://ip:8443