Search code examples
javaamazon-web-servicesspring-securitythymeleafamazon-ecs

The "redirect" routing of thymeleaf is redirecting the application to http and not to https when deployed in AWS ECS


I am building a Spring Boot application which consists of Spring Security and Thymeleaf. I have deployed this application in Elastic Container Service (ECS) cluster of AWS.

I have my simple controller code for the homepage which looks like return "redirect:/login". But as soon as I am hitting the homepage it is converting the URL to the http and not https.

The whole application is accessible through https://abcd.com/login but the "redirect" routing of Thymeleaf is always redirecting it to the http://abcd.com/login which is not accessible.

Can anyone help with the resolution for this.?

Also the ECS has one service, one load balancer and one Route53 for translating the names to IP address.


Solution

  • Sounds like you are running with https offloading (meaning, that your spring boot application does not receive the https request but rather an http request, the load balancer terminates the tls connection).

    I think your problem is described in the spring boot documentation. In most cases the solution is to set server.forward-headers-strategy=NATIVE in your application.yaml.