I have Django installed on a corporate intranet, running on Apache using mod_wsgi. The Apache server has SSL set up, and everything is working as expected when users hit CGI pages, but my django applications don’t seem to be picking up any SSL related environment variables (ssl_client_s_dn, etc) whether they go to my django pages with http:// or https://.
I think the main issue is that I don’t understand where django is pulling it’s os.environ from, and how to change that. I’ve looked through the official django documentation and other posts on ‘django’ and ‘ssl’, but those seem to deal with views that need to sometimes be http, and sometimes https. I am just trying to get ssl related information to show up in os.environ at all, and I don’t know where to look next.
What do you need to know? httpd.conf wsgi configuration settings? My projects settings.py, or lines in wsgi.py?
Any help is much appreciated.
If you are using
mod_wsgiwithin Apache, and you set the environment variables in Apache (usingSetEnv), then you are out of luck:mod_wsgi‘s environment variables are separate from these in Apache.Many people are running into similar problems, when setting variable in Apache using
SetEnvis completely invisible when trying to accessos.environin Django.There is however some solution. It is listed here, and basically comes to these lines in your wsgi script (adjusted to your needs):
Which basically translates first argument of your WSGI application into
os.environdictionary. For details see the post linked above.