Reputation: 9980
I've just inherited a Python application which is running under Apache 2.4, mod_wsgi 3.4 and Python 2.7. The same application serves both HTTP and HTTPS requests.
In the existing code, it is trying to determine if the reqeust was HTTPS by checking the environment:
if context.environ.get('HTTPS') not in ['on', '1']:
This check is failing, even when the connection actually was HTTPS. On looking at an extended traceback showing the environment variables, I saw that HTTPS
was not actually in the environment passed from Apache.
So my questions are:
Upvotes: 0
Views: 1696
Reputation: 27772
Apache's mod_ssl
can be configured to set the HTTPS
environment variable, but doesn't do so by default for performance reasons.
You could explicitly enable it, but since you're using a WSGI application, it's probably a better idea to check the wsgi.url_scheme
environment variable instead; the WSGI spec guarantees its presence, and it won't require any further changes to your application if you do eventually move to nginx.
Upvotes: 4