Redirect Http to Https in Elastic BeansTalk, Tomcat, Nginx

Viewed 1256

I have a spring boot application (1.5.3) which is running on a Tomcat container with Nginx as the load balancer. I have created below file:

.ebextentions/nginx/conf.d/myapp.conf

And I added the below content based on this article:

server {
  if ($http_x_forwarded_proto != 'https') {
    rewrite ^(.*) https://$host$1 redirect;
  }
}

I have installed SSL certificate in certificate manager and set it in my environment. Now the application serves both HTTP and https request. I want to redirect all HTTP requests to https without falling into a redirect loop. but doesn't work.

1 Answers
Related