小编典典

IBM Bluemix在Spring Boot应用程序上强制执行https(生成的Jhipster)

tomcat

我需要对部署在IBM Bluemix上的spring-
boot应用程序(生成的jhipster)强制执行https。不需要在StackoverFlow上的许多答案指定的下方添加标题。

server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto

我还在安全配置中添加了以下代码

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

仍然没有将我的应用重定向到https。

我也怀疑是否曾经在bluemix域上执行https,是否同样适用于自定义域?

谢谢,瓦苏


阅读 252

收藏
2020-06-16

共1个答案

小编典典

应用Yaml配置

服务器:

  tomcat:
     remote_ip_header: x-forwarded-for
     protocol_header: x-forwarded-proto

上面的tomcat标头告诉服务器原始请求是http还是https,

在ResourceServerConfigurerAdapter中的configure(…)方法重写:configure(…)中,我们必须添加以下行

如果(profile.equalsIgnoreCase(Constants.SPRING_PROFILE_PRODUCTION)){http.requiresChannel()。anyRequest()。requiresSecure();
}

2020-06-16