Django request.is_secure returns invalid value for redirected methods

I am trying to write an ssl redirect utility for django applications (https://bitbucket.org/yilmazhuseyin/django-sslredirector). My problem is that when I redirect pages from http to https, I cannot understand that I am in a secure connection (when I call request.is_secure, it returns false). I think there is a hack to this, one way or another called Webfaction, that I can’t understand how it works. here the is_secure method is used for the case of webfaction

   def _is_secure(self, request):
        if request.is_secure():
        return True

        #Handle the Webfaction case until this gets resolved in the request.is_secure()
        if 'HTTP_X_FORWARDED_SSL' in request.META:
        return request.META['HTTP_X_FORWARDED_SSL'] == 'on'

My problem is that when I redirect my pages from http to https, the request.is_secure method still returns false (an event, although I am on https), and I constantly redirect my pages to https. Is there any way to understand if I'm just redirected from https?

The best source I could find is http://djangosnippets.org/snippets/880/ and it does not work for me

+5
source share
1 answer

- -, , , SSL, . - HTTP- ( ). - HTTP_X_FORWARDED_SSL. Heroku HTTP_X_FORWARDED_PROTO https, https.

+5

All Articles