On Jul 17, 5:24 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > We're running a production setup with nginx running in front of > apaches runningmod_python. Nginx is decoding all ssl and reverse > proxying (the decrypted requests) to apache on the backend. We > recently upgradedmod_pythonand are now running into an issue because > of this django code... > > def is_secure(self): > try: > return self._req.is_https() > except AttributeError: > #mod_python< 3.2.10 doesn't have req.is_https(). > return self._req.subprocess_env.get('HTTPS', '').lower() > in ('on', '1') > > Since our version ofmod_pythonis now greater than 3.2.10 it calls > is_https which returns that the request is unencryped (as that is what > apache sees since nginx has decrypted the request. With the old > version ofmod_pythonI was setting a header in nginx which apache > then read with a SetEnvIf directive and set the HTTPS variable > appropriately. I'm looking for a similar solution to do so that > self._req.is_https() in the above code returns true. Is there a way to > do this without hacking upmod_python, or do I just have to patch > django's is_secure method to act as if I were still running the old > version ofmod_python(and thus run > self._req.subprocess_env.get('HTTPS', '').lower() in ('on', '1')).
If you were using a WSGI hosting mechanism (eg. mod_wsgi, fastcgi etc), this would be somewhat easier to do, as you would just need to override the flag in WSGI environ. Eg. import os, sys sys.path.append('/usr/local/django') os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() def application(environ, start_response): environ['wsgi.url_scheme'] = 'https' return _application(environ, start_response) Sorry, don't have an easy answer for Django. Graham --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---