The aws load balancer forwards all https requests onto the ec2 instance over port 80. I need to somehow redirect all http request on to https.
What I've gathered thus far is you need to somehow modify the ec2 instance with the redirect rules and then save the instance as a new AMI and point beanstalk to the new AMI.
I found the following rewrite rule, but unfortunately I don't know what to do with it.
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^/(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
I ssh'd into my ec2 instance and went to /etc/httpd/
and that's as far as I made it. I'm completely lost with what I'm suppose to do from there.
- Do I modify a file or do I create a new file?
- If I need to modify or create a new file, where would it be or what would I call it and where would it go?
- Could someone provide the exact contents of the file
- Once I create/modify this file what do I do next? Do I just go to the ec2 page, click on the checkbox next to my instance, click actions, and finally create image?
If so, what does all this mean? I don't know what settings I'm suppose to have here.
Lastly, I'm assuming I just go to configuration in my beanstalk dashboard and just point my beanstalk env to my new AMI and restart the server. Does this sound correct?
If someone knows how to do this or a website describing the process in detail I'd appriciate it.
I'd like to point out that I'm using a java app on tomcat. I'm not sure if a custom AMI would effect scaling up of server sizes either.