简体   繁体   中英

Force HTTPS on Appharbor

Related questions: here - here

I have an ASP.NET application deployed on appharbor. Manually navigating to its https:// url works fine, but I would like to ONLY use HTTPS. That is, redirect to HTTPS if I receive an HTTP request.

There are 2 ways of achieving this, that I'm aware of: (1) using web.config , which does not work due to the X-Forwarded-Proto header being stripped by the load-balancer on appharbor (?) or (2) making a custom httpattribute as shown here

Unfortunately, neither of these approaches work well for me - Both are giving me a redirect loop :(. All the answers I can find are fairly old, has anything changed on appharbor/asp.net that I should be aware of?

Thanks in advance.

Are you using MVC in your application? The attribute was intended for it.

If it's just regular ASP.NET you could use HTTP Modules or Global.asax to achieve the same effect.

The RequireHttpsAttribute by Rune should work. I use ServiceStack on AppHarbor, but based the attribute I use for that from Rune's code. It's still in use today.

AppHb's load-balancer will set the X-Forwarded-Proto header to match the incoming protocol scheme (http or https), as traffic from the load balancer is forwarded on to your application's IIS instance as HTTP (and therefore the original scheme is lost).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM