I had a bit of a difficulty with enabling https redirects on a Elastic Beanstalk deployment with a Rails Application behind a Load Balancer.
For a Rails app running behind passenger, the nginx config for the load balancer is generated from an ERB template, instead of a custom nginx config file you can just upload like many blogposts I saw about the issue suggested.
We’ll need to copy the whole file and put it under our
.ebextensions folder. The code that performs the redirect is already included in that file as the first location directive that was added and is noted below. We’ll be redirecting all requests to https, while retaining the parameters, except the requests that go to the health check URL.