In recent times I’ve had to handle the Microsoft stack (.NET) among other things. One of the things I’ve faced recently was redirecting traffic hitting the application running on IIS behind an AWS Elastic Load Balancer (ELB) from HTTP to HTTPS. Fairly easy on the Linux stacks which had nginx in front as a reverse proxy (just add a rewrite rule on your HTTP host to HTTPS), but after tinkering around a bit, finally got the correct rewrite rule working (with the help of IIS7’s .htaccess conversion utility).
The transform code you would want to stick into your Web.
<rewrite xdt:Transform="Insert"> <rules> <rule name="HTTPS rewrite behind ELB rule" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions> <add input="{HTTP_X_FORWARDED_PROTO}" pattern="^http$" ignoreCase="false" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{SERVER_NAME}{URL}" /> </rule> </rules> </rewrite>
This assumes you have the IIS URL Rewrite module installed on your IIS server.
References:
http://www.iis-aid.com/articles/how_to_guides/redirect_http_to_https_iis_7?page=1 http://serverfault.com/questions/304621/endless-redirect-loop-with-aws-elb-and-wordpress-site-using-wordpress-https-plugi http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/index.html?SvcIntro.html