Azure has done a fantastic job of making it easy to deploy a NodeJS application to Azure Web Sites. However, one thing that took a bit of searching to find is how to force Azure Web Sites to only serve https requests. Fortunately this is really easy. I found the answer on Scott Hanselman’s blog but I am also posting it here.
Add the following to you Web.config. (In Azure Web Sites nodejs is hosted behind IIS and the web.config controls how IIS behaves.)
<rewrite> <rules> <clear /> <rule name="Redirect to https"> <match url="(.*)"/> <conditions> <add input="{HTTPS}" pattern="Off"/> <add input="{REQUEST_METHOD}" pattern="^get$|^head$|^post$" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/> </rule> <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true"> <match url="iisnode.+" negate="true" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Rewrite" url="bin\www" /> </rule> </rules> </rewrite>
Reblogged this on Dinesh Ram Kali..