我们正在使用nginx(启用代理SSL),Spring boot1.2.2和keycloak 1.9.8。 我们正在将spring boot应用程序部署为jar并完成必要的设置 对于application.properties中的keycloak。没有SSL一切正常 但每当我们使用SSL时,Spring启动应用程序都不会转发 proto(https)和端口(8443)到keycloak所以我们总是无效 redirect_uri例外。
I tried setting follwing configuration in application.properties
server.tomcat.remote-ip-header=x-forwarded-for
server.tomcat.protocol-header=x-forwarded-proto
server.tomcat.protocol-header=x-forwarded-port
Please suggest what needs to be done.
Thanks & Regards,
Chandrashekhar
答案 0 :(得分:2)
问题已解决。我们通过spring Initializer类在嵌入式tomcat容器中实际设置了proto和port。
@Override
public void customize(final ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
//final TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(connector -> {
connector.setScheme("https");
connector.setProxyPort(443);
//connector.setScheme("https");
//connector.setProxyPort(8443);
//connector.setScheme("http");
//connector.setProxyPort(8080);
});
LOGGER.info("Enabled secure scheme (https).");
} else {
LOGGER.warn("Could not change protocol scheme because Tomcat is not used as servlet container.");
}
}