I want to redirect traffic from http to https on my load balanced node.js instance running on Amazon Linux + nginx on elastic beanstalk.
I configured the load balancer to route traffic on port 80 and 443 to the instance:
When I access the page with https://url.com I have a secure https connection but I can still force http by opening the url with http://url.com.
I want to prevent this by forcing the incoming traffic on port 80 to be redirected to 443.
I found this configuration file in the official AWS documentation: https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/security-configuration/https-redirect/nodejs/https-redirect-nodejs.config
I created an .ebextensions folder and placed the configuration file in there. I deployed the application but the redirection still does not work. Has anybody solved this kind of problem? Anything else I could try?
In EB you can use Classic, network and application load balances. If you expect http and https traffic only, switch to Application ELB and do http to https redirection on ELB. Moreover you can request for SSL certificate in ACM (for free) and attache it to your SLL listener.