Search code examples
asp.net-mvcsslappharbor

Error on AppHarbor The requested resource can only be accessed via SSL


I have a strange error popping in my error logs file. I'm using the custom RequireHttpsAttribute from AppHarbor: https://gist.github.com/915869.

I have this attribute on my home controller, and it's working fine, but I would say that 5-10 times per day some requests failed with the following error:

The requested resource can only be accessed via SSL.
Stack Trace:
   at System.Web.Mvc.RequireHttpsAttribute.HandleNonHttpsRequest(AuthorizationContext filterContext)
   at Osmosis.RequireHttpsAttribute.OnAuthorization(AuthorizationContext filterContext) in d:\temp\bfzenor31c\input\prj\Infrastructure\Extensibility\RequireHttpsAttribute.cs:line 35
   at System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__1e(AsyncCallback asyncCallback, Object asyncState

The line 35 from the RequireHttpsAttribute is the following:

HandleNonHttpsRequest(filterContext);

So the "https" was not supplied in the "X-Forwarded-Proto" request header. But the redirection to the https failed for a reason that I don't understand.

This is the url requested: http://www.mydomain.com:14685/, controller home action index which have the [RequireHttps] attribute.

Any pointers would be appreciated.


Solution

  • AppHarbor will make requests like this to your site whenever a new version is deployed. This is part of the pre-warming process, and I think it's the likely source of your problem.

    We'll think about ways to avoid this showing up as an error for you.