首页 文章

在spring boot embedded下载时将http重定向到https

提问于
浏览
2

我使用的是 spring 靴(1.2.3)和嵌入式底板 . 出于安全原因,我宁愿将任何http请求重定向到https,但我找不到这样做的示例 .

以下是spring boot和tomcat的示例:Spring boot - Embeded Tomcat HTTP to HTTPS redirect

有没有人有这样做的解决方案?

2 回答

  • 0

    您可以将Spring-Security添加到项目中,然后配置Spring-Security以强制执行https . 你可以在JavaDoc中找到一个小例子

    org.springframework.security.config.annotation.web.builders.HttpSecurity#requiresChannel()
    
  • 3

    实际上你在Spring Boot应用程序中将有2个端口,因此你必须创建另一个EmbeddedServletContainerFactory来告诉新端口http或https . 创建新端口后,您可以使用Spring Mvc或Spring Security管理重定向 .

相关问题