Ssl Spring引导应用程序上的Bluemix强制HTTPS

Ssl Spring引导应用程序上的Bluemix强制HTTPS,ssl,spring-security,spring-boot,ibm-cloud,cloud-foundry,Ssl,Spring Security,Spring Boot,Ibm Cloud,Cloud Foundry,我有一个Spring Boot应用程序,它作为CF应用程序推送到Bluemix上。 它与http协议一起有效地工作。然而,如果我试图强制https,我会得到一个502错误 我有: @Configuration class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception {

我有一个Spring Boot应用程序,它作为CF应用程序推送到Bluemix上。 它与http协议一起有效地工作。然而,如果我试图强制https,我会得到一个502错误

我有:

@Configuration
class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
        http.requiresChannel().anyRequest().requiresSecure();
        //http.csrf().disable();
  }

}
我有一个
application.properties
文件,其中包含以下条目:

server.ssl.key-store = classpath:**.jks
server.ssl.key-store-password = *******
server.ssl.key-password = ******

server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto
我知道Bluemix执行SSL终止;事实上,它正确地设置了x-forwarded-proto和x-forwarded-for。我在寻找像和这样的解决方案,但没有任何运气

然后,我尝试了以下解决方案,如中所建议,但收到了一个重定向循环:

@Bean
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory(){
    return new TomcatEmbeddedServletContainerFactory() {
        @Override
        protected void postProcessContext(Context context) {
            SecurityConstraint securityConstraint = new SecurityConstraint();
            securityConstraint.setUserConstraint("CONFIDENTIAL");
            SecurityCollection collection = new SecurityCollection();
            collection.addPattern("/*");
            securityConstraint.addCollection(collection);
            context.addConstraint(securityConstraint);
        }
    };
}

我的方法遗漏了什么?非常感谢您为我提供的任何提示/建议

为了社区的利益,如果Rob的评论被接受为答案,那就太好了。Rob,如果你愿意看到答案被接受,请随意添加你自己的答案

Tomcat没有检测到x转发头是受信任的代理。尝试设置server.tomcat.internal proxy=.*和logging.level.org.apache.catalina.valves=DEBUG


我猜Tomcat没有检测到x转发头是可信代理。尝试设置server.tomcat.internal proxy=.*和logging.level.org.apache.catalina.valves=DEBUGThank!它确实有助于找到解决方案!为完整起见,由于Bluemix已经执行了SSL验证,我删除了服务器。SSL.*部分ad添加了以下内容:
server.tomcat.internal proxies=.*server.use forward headers=true
现在它像一个符咒一样工作,还执行HTTP到HTTPS重定向。再次感谢你的帮助