http - 为 bluemix api 调用禁用 HTTP

标签 http https ibm-cloud

我正在 bluemix 中为 REST API 运行一个 spring-boot 应用程序。 目前,API 调用在 http 和 https 中均有效。 如何禁用 http?你怎么看?

最佳答案

在spring-boot的application.properties文件中添加如下两行

server.tomcat.internal-proxies=.*
server.use-forward-headers=true

添加如下spring配置bean

@Configuration
public class SecurityConfiguration {
    @Bean
    public EmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {

        TomcatEmbeddedServletContainerFactory tomcat = 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);
            }
        };
        return tomcat;
    }
}

由于 HTTPS 已在 bluemix 中实现,如果我们可以将 http 调用路由到 https 就足够了。但无论如何,我很想知道是否有人知道要覆盖它并强制执行他们自己的安全证书?

关于http - 为 bluemix api 调用禁用 HTTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45589126/

相关文章:

windows - 如何在Windows上配置IBM Kubernetes CLI

apache-kafka - Kafka 从提交失败异常中恢复

rest - 如何在jmeter中以unix格式获取当前UTC时间

https - 如何使用 Clojure 读取 https 请求?

ssl - 系统无法从 xxxx url 推断传输信息

ruby-on-rails - 配置 WEBrick 以使用自动生成的自签名 SSL/HTTPS 证书

Node.JS - 将 max-old-space-size 设置得太大有什么副作用吗?

mongodb - 按服务器状态更改 HTTP 路由

php - Laravel:在哪里抛出 HTTP 异常

http - 关于 URL 的可用性是否有任何安全的假设?