所需信息:
我正在一个Spring项目中使用Keycloak(Docker版本)。
(此项目的客户端是React,并且客户端和后端之间的通信由REST服务提供。)
客户端已经被安全保护,使用“https”协议。
以下是我的Spring配置:
keycloak:
auth-server-url: https://sso-ssoha.b9ad.pro-us-east-1.openshiftapps.com/auth
realm: master
resource: clientname
public-client: true
问题的根源:
当我从客户端点击链接时,它通常会调用Spring服务。但在此之前,它会将当前的“https” url 添加路径sso/login,并将方案更改为“http”,然后重定向到Keycloak的默认登录页面。
但是,从https重定向到http会导致以下问题:
Mixed Content: The page at 'https://www.helpful.army/contents/Problem' was loaded over HTTPS, but requested an insecure resource 'http://serviceha-helpfularmy.b9ad.pro-us-east-1.openshiftapps.com/sso/login'. This request has been blocked; the content must be served over HTTPS.
location / { try_files $uri /index.html; } location ~ \.css { add_header Content-Type text/css; } location ~ \.js { add_header Content-Type application/x-javascript; } }
} - Altay Hunoğlu