title: Server Variables not being set
body: <p>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.</p>
  
  <p>I have created a rewrite rule in IIS 8.5 to set the SERVER_PORT and HTTPS server variables:</p>
  
  <pre><code>&lt;rewrite&gt;
                  &lt;allowedServerVariables&gt;
                  &lt;add name="SERVER_PORT" /&gt;
                  &lt;add name="HTTPS" /&gt;
              &lt;/allowedServerVariables&gt;
       &lt;globalRules&gt;
              &lt;rule name="HTTPs Redirect"&gt;
                  &lt;match url="(.*)" /&gt;
                  &lt;conditions&gt;
                      &lt;add input="{ALL_HTTP}" matchType="Pattern" 
                           pattern="HTTP_X_FORWARDED_PROTO:https" ignoreCase="true" /&gt;
                  &lt;/conditions&gt;
                                      &lt;serverVariables&gt;
                         &lt;set name="SERVER_PORT" value="443" /&gt;
              &lt;set name="HTTPS" value="on" /&gt;
                      &lt;/serverVariables&gt;
                      &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /&gt;
  
              &lt;/rule&gt;
            &lt;/globalRules&gt;
  
          &lt;/rewrite&gt;
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>&lt;%
  
  foreach (string var in Request.ServerVariables)
  {
    Response.Write(var + " " + Request[var] + "&lt;br /&gt;");
  }
  
  %&gt;
  </code></pre>
  
  <p>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?</p>
  
  <p>Thanks</p>
  
  <p>Luke</p>