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
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
source
share