René Reitmann
René Reitmann

Reputation: 364

Redirect http to https on spring boot embedded undertow

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?

Upvotes: 4

Views: 2481

Answers (3)

Telamon
Telamon

Reputation: 76

Imho this is a concern of a reverse proxy that is handling the http traffic before it comes to your application. Would that be an option for you?

Upvotes: -1

Carlos Alberto
Carlos Alberto

Reputation: 8605

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.

Upvotes: 0

Chris
Chris

Reputation: 46

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

Upvotes: 3

Related Questions