4
votes

Steps I have taken:

  1. Enabled 80 HTTP -> 80 HTTP and 443 HTTPS -> 80 HTTP on my load balancer in Elastic Beanstalk
  2. Aliased my Route53 hosted zone for both www and apex A records to my load balancer
  3. Set up the SSL certificate
  4. Used the default ASP.NET React Template with HTTPS Redirection
  5. Added <RuntimeIdentifier>win-x64</RuntimeIdentifier> in .csproj since EB doesn't use 2.1 yet.
  6. Deployed with Visual Studio AWS Tools

What works:
https://www.example.com works
https://example.com works

What doesn't work:
http://example.com won't redirect to https://example.com
http://www.example.com won't redirect to https://www.example.com

I know in the past you had to write custom extension methods to get this to work with AWS LBs. Does anyone have a working example using the standard templates?

1
Have you tried x-forwarded headers? Here more infoOscar André
Yes, didn't work for me. Surely someone has done this with EB and AWS Load Balancers with Core 2.1davidhenley
can you provide more info?... Maybe, you can configure the asp.net core project without https support and let the reverse proxy (IIS, nginx, etc) do the redirect work. This can help youOscar André
did you get this working? looking for a solutionraklos

1 Answers

0
votes

Maybe this solution is a little overkill for your environment. But you could set up a Cloudfront distribution. You should put your Elastic beanstalk url as origin and your https://example.com under CNAME, then you can decide if you want flexible SSL you can specify communication with the origin as HTTP only, or if you want end to end encryption you can specify HTTPS only (I think this would be the way to go in your particular case since you have configured your elastic load balancer to forward all requests from port 443 to port 80). Then under behavior you can select the option to redirect http to https and every request to http://example.com will be automatically redirected by Cloudfront to https://example.com

I hope this helps