Reputation: 28555
I am using Elastic Beanstalk on AWS for a .net core site hosted on IIS.
I'm unsure how to get http to redirect to https. Following this:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-httpredirect.html
I have done the first step, but unsure what to do in the second step. I'v followed the github link, but dont know what to do with the file.
Instructions are unclear.
I'm open to suggestions of other methods of getting http to redirect to https
Upvotes: 2
Views: 1056
Reputation: 138
I was confused by all the documentation and answers providing code for rewrite rules, which I could never get to work. I eventually figured out how to do this via the AWS web console:
Make sure you are using an Application Load Balancer for your application's environment.
Add a listener for https, port 443, and your certificate (AWS documentation covers this quite well)
This was the part that took me hours to figure out:
You cannot configure the redirect from Elastic Beanstalk's load balancer configuration section. You have to go to Services -> EC2 -> Load balancers
and then select the load balancer created for your application/environment.
If you have multiple load balancers, it's hard to determine which one is the correct one. I had to refer to the "Created At" timestamp to know which one to select.
Click the "Listeners" tab
Upvotes: 5
Reputation: 28555
This is what worked for me https://stackoverflow.com/a/47806650/66975
<rewrite>
<rules>
<rule name="HTTPS Rule behind AWS Elastic Load Balancer Rule" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="^http$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}{URL}" redirectType="Found" />
</rule>
</rules>
</rewrite>
Upvotes: 0