KeyCloak5.0版本使用nginx代理解决HTTPS域名的问题

第一个问题:

java.sql.SQLException: Can not call getNString() when field's charset isn't UTF-8

UTF-8的编码问题,在指定编码的时候必须使用大写的UTF-8,不能使用小写的UTF-8


    
    jdbc:mysql://172.17.4.178:3306/keycloak?characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
    
    mysql
    
        20
    
    
		daxian
		zhudaxian;.,68NB
    

第二个问题:nginx代理https域名,内部使用http的转向报错

error=invalid_redirect_uri, redirect_uri=https://auth.zhubanxian.com/auth/admin/master/console/

解决方法:

第一步修改nginx配置,指定转发的协议为https:  proxy_set_header X-Forwarded-Proto https;

        upstream auth{
                server 172.17.4.178:8180  weight=1;
        }

        server {
                listen 443;
                server_name auth.zhubanxian.com;

                ssl on;
                ssl_certificate /etc/nginx/vhosts/auth/auth.pem;
                ssl_certificate_key /etc/nginx/vhosts/auth/auth.key;
                ssl_session_timeout 5m;
                ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
                ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                ssl_prefer_server_ciphers on;

                location ~ ^/(.*){
                        proxy_pass http://auth;
                        proxy_set_header REMOTE_ADDR $remote_addr;
                        proxy_set_header Host $http_host;
                        #指定转发的协议为https
                        proxy_set_header X-Forwarded-Proto https;
                        proxy_pass_header Authorization;
                        proxy_http_version 1.1;
                        proxy_set_header Connection "";
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";
                }

        }

第二步:修改standalone.xml,增加属性配置 :proxy-address-forwarding="true"


    
    
    
        
        
    

重启keycloak,重新访问成功。

你可能感兴趣的:(keycloak)