首页 文章

在jhipster中将http重定向到https

提问于
浏览
0

我有一个使用Spring Boot的jhipster(4.14.5)单片应用程序,它在 生产环境 时使用http v2运行,并使用证书强制ssl . 应用程序服务器使用使用自动构建器(这是jhipster中的标准配置)创建的嵌入式下载容器 .

不幸的是,它不会自动转发在浏览器中使用http的 生产环境 服务器上的用户https . 我尝试了很多不同的解决方案来解决这个问题

security:
  require-ssl: true

在application-prod.yml中

http.requiresChannel().anyRequest().requiresSecure()
and.portMapper().http(80).mapsTo(443)

在SecurityConfiguration中

underTowContainer.addBuilderCustomizers(builder -> builder.addHttpListener(80, hostAddress));
        underTowContainer.addDeploymentInfoCustomizers(deploymentInfo -> {
            deploymentInfo.addSecurityConstraint(new SecurityConstraint()
                .addWebResourceCollection(new WebResourceCollection().addUrlPattern("/*"))
                .setTransportGuaranteeType(TransportGuaranteeType.CONFIDENTIAL)
                .setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.PERMIT))
                .setConfidentialPortManager(exchange -> 443);
        });

在WebConfigurer中

但是,到目前为止还没有办法 . 我有什么想法可以试试吗?

1 回答

  • 0

    你使用像nginx或负载均衡器之类的代理吗?我建议用它来进行https转发 .

相关问题