Forcing HTTPS on AWS EC2 load-balancer cluster

Recently i had to force rewrite HTTP to HTTPS on servers running under an AWS EC2 load-balancer. My first instinct was to add rewrite rule like the one below.

But that did not work and after a bit of debugging i was able to figure out that it was …