java - 在 spring boot embedded undertow 上将 http 重定向到 https

标签 java spring spring-boot undertow

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

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

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

最佳答案

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

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

关于java - 在 spring boot embedded undertow 上将 http 重定向到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30645167/

相关文章:

java - 如何实现触发Spring-Data Repository的Before/After save方法

java - 为什么我的 Java 服务器关闭套接字?

java - 简单的 Mockito 测试(Spring + Dao)

java - H2数据库是否兼容Oracle 'Insert All'语句?

spring - 在 Spring STS 中通过 maven 项目连接到 postgreSQL

eclipse - Eclipse 中 Maven Spring Boot 项目的部署程序集

java - 处理客户端请求中的空通量体

java - 从程序中获取时间复杂度和空间复杂度

java - 在放置、发布和删除之前进行 Spring Boot 验证

java - 不情愿的量词在 Javascript 中不起作用