I have a load balanced webserver environment using a NetScaler load-balancer which is configured to add the header HTTP_X_FORWARDED_PROTO. This is either http / https depending on the request. I know that this header is coming through correctly.
I have created a rewrite rule in IIS 8.5 to set the SERVER_PORT and HTTPS server variables:
<rewrite>
<allowedServerVariables>
<add name="SERVER_PORT" />
<add name="HTTPS" />
</allowedServerVariables>
<globalRules>
<rule name="HTTPs Redirect">
<match url="(.*)" />
<conditions>
<add input="{ALL_HTTP}" matchType="Pattern"
pattern="HTTP_X_FORWARDED_PROTO:https" ignoreCase="true" />
</conditions>
<serverVariables>
<set name="SERVER_PORT" value="443" />
<set name="HTTPS" value="on" />
</serverVariables>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</globalRules>
</rewrite>
However the headers do not appear to change? I know the rule is working because I added an action to redirect to google.com and could see that working. I have a page that displays all the server varibles with this code:
<%
foreach (string var in Request.ServerVariables)
{
Response.Write(var + " " + Request[var] + "<br />");
}
%>
I am really banging my head against the wall on this one, I have searched and searched online and can't see why it is not working?
Thanks
Luke