title: Configuring "RequireHttpsAttribute" filter to account for X-Forwarded-Proto
body: <p>I am hosting a ASP.NET Framework application on AWS elastic bean, and I am using a load balancer.</p>
  
  <p>Using my current configuration to require https results in infinite loops because the load balancers are using http to communicate with the server. In order to have my filter function i need to account for the X-Forwarded-Proto Header, which from my understanding contains the original requests protocol.
  I do understand what is wrong, but I not understand how I can use this attribute in order to ensure a secure connection.</p>
  
  <p>This is my current config:</p>
  
  <pre><code>public class RequireHttpsAttribute : AuthorizationFilterAttribute {
  
      public int Port { get; set; }
  
      public RequireHttpsAttribute()
      {
          Port = 443;
      }
  
          public override void OnAuthorization(HttpActionContext actionContext)
          {
              var request = actionContext.Request;
  
              if (request.RequestUri.Scheme != Uri.UriSchemeHttps)
              {
                  var response = new HttpResponseMessage();
  
                  if (request.Method == HttpMethod.Get || request.Method == HttpMethod.Head)
                  {
                      var uri = new UriBuilder(request.RequestUri);
                      uri.Scheme = Uri.UriSchemeHttps;
                      uri.Port = this.Port;
  
                      response.StatusCode = HttpStatusCode.Found;
                      response.Headers.Location = uri.Uri;
                  }
                  else
                  {
                      response.StatusCode = HttpStatusCode.Forbidden;
                  }
  
                  actionContext.Response = response;
              }
              else
              {
                  base.OnAuthorization(actionContext);
              }
          }
  }
  </code></pre>
  
  <p>This filter config is added to my WebApiConfig.</p>
  
  <p>My question is:
  How do check for the X-Forwarded-Proto in this filter?</p>