Redirect http to https on spring boot embedded undertow

淺唱寂寞╮ 提交于 2019-12-11 03:47:47

问题


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.

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

Does anyone have a solution for doing this with undertow?


回答1:


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()



回答2:


Actually you're gonna have 2 ports in Spring Boot application, so you will have to create another EmbeddedServletContainerFactory telling the new port either http or https. Once the new port is created you can manage the redirect using Spring Mvc or Spring Security.



来源:https://stackoverflow.com/questions/30645167/redirect-http-to-https-on-spring-boot-embedded-undertow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!