本文介绍了在 spring boot 嵌入式 undertow 上将 http 重定向到 https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using spring boot (1.2.3) and embedded undertow. For security reasons I would prefer to redirect any http request to https but I cannot find an example for doing this.

下面是spring boot和tomcat的例子:Spring Boot - 嵌入 Tomcat HTTP 到 HTTPS 重定向

Here is an example for spring boot and tomcat:Spring boot - Embeded Tomcat HTTP to HTTPS redirect

有没有人有使用 undertow 执行此操作的解决方案?

Does anyone have a solution for doing this with undertow?

推荐答案

您可以将 Spring-Security 添加到您的项目中,然后配置 Spring-Security 以强制实施 https.你可以在

you could add Spring-Security to your project and then configure Spring-Security to enforce https. You could find a small example in the JavaDoc of

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

这篇关于在 spring boot 嵌入式 undertow 上将 http 重定向到 https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 18:47