Hi there,
The *** in the configuration file are actually just redacted/masked information.
I tried removing the SSLCertificateChainFile and it had no effect, so I think it’s safe to leave it out. Ours are “real” certs issued by InCommon.
Thanks for the info using pip / mod_wsgi-express- I will give that a try before moving on to tying some request logging and then Nginx/other components.
—Jennifer
>>> Setting DEBUG False seems to break my application - I get a “Bad Request 400” error back in my browser - so I will check in with the developer on that one.
>>>
>>> I’ve removed the extraneous environment variables and also the SSL proxy setting. I am only using mod_wsgi with Apache, so, as you say, it shouldn’t need that anyhow.
>>>
>>> I’ve done the test for the /wsgicheck and it does return a value of https. Thanks for helping me verify that functionality.
>>>
>>> So, this leaves me with looking at Apache as a culprit - or again, the Django code itself. It’s very odd how only the two browsers are showing issues and they are completely different issues…
>>>
>>> thanks,
>>> Jennifer
>>>
>>>
>>>
>>>> On Dec 16, 2014, at 4:41 PM, Graham Dumpleton <
graham.d...@gmail.com> wrote:
>>>>
>>>> Hmmm, this looks really dangerous:
>>>>
>>>> DEBUG "FALSE"
>>>>
>>>> The DEBUG setting is meant to be a boolean value, not a string.
>>>>
>>>> Because you are setting it to a non empty string, it will be interpreted as True and so you have debug mode enabled.
>>>>
>>>> That is not good as sensitive information could be exposed back to users in error pages shown in the browser.
>>>>
>>>> Running in debug mode might cause other issues as well.
>>>>
>>>> Ensure you are setting it to:
>>>>
>>>> DEBUG False
>>>>
>>>> Also, setting:
>>>>
>>>> os.environ['HTTPS'] "on"
>>>> os.environ['wsgi.url_scheme'] 'https'
>>>>
>>>> will not do anything.
>>>>
>>>> The wsgi.url_scheme is an attribute which is passed down by mod_wsgi in the details for each request. A web framework will use the flag from the request details. The main thing it controls is merely the construction of absolute URLs when needing to be added to response headers or maybe response content in some cases.
>>>>
>>>> In other words, you do not need to set it and setting it in environment variables wouldn't do anything anyway.
>>>>
>>>> Next, setting:
>>>>
>>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
>>>>
>>>> is okay if you have just the one Django site, but be careful in using this if you are running more than one. Safer to use:
>>>>
>>>> os.environ["DJANGO_SETTINGS_MODULE"] "myproject.settings"
>>>> SECURE_PROXY_SSL_HEADER ('HTTP_X_FORWARDED_PROTO', 'https')
>>>>
>>>> if Apache is your front facing web server. You would only need this if you had a further front end proxy such as nginx in front of Apache and nginx had been configured to actually introduce these headers. That your Apache is accepting HTTPS requests would indicate that you don't have an nginx in front.
>>>>
>>>> Now as to determine whether wsgi.url_scheme is set properly, the easiest way is to take a copy of:
>>>>
>>>> def application(environ, start_response):
>>>> status '200 OK'
>>>> output str(environ.get('wsgi.url_scheme'))
>>>>
>>>> response_headers [('Content-type', 'text/plain'),
>>>>> os.environ['HTTPS'] "on"
>>>>>
>>>>> # This application object is used by any WSGI server configured to use this
>>>>> # file. This includes Django's development server, if the WSGI_APPLICATION
>>>>> # setting points here.
>>>>> from django.core.wsgi import get_wsgi_application
>>>>> application get_wsgi_application()
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> and here is relevant stuff from my settings.py file:
>>>>>
>>>>> import os
>>>>> PROJECT_ROOT os.path.realpath(os.path.dirname(__file__))
>>>>>
>>>>>
>>>>> #turn off debug when going to production
>>>>> DEBUG "FALSE"
>>>>> TEMPLATE_DEBUG DEBUG
>>>>>
>>>>>
>>>>> # Python dotted path to the WSGI application used by Django's runserver.
>>>>> WSGI_APPLICATION 'myproject.wsgi.application'
>>>>>
>>>>>
>>>>> #session expire at browser close
>>>>> SESSION_EXPIRE_AT_BROWSER_CLOSE True
>>>>> SESSION_COOKIE_HTTPONLY=True
>>>>>
>>>>> #idle timeout
>>>>> SESSION_IDLE_TIMEOUT�0
>>>>>
>>>>> #HTTPS stuff - secure proxy SSL header - do I need this?
>>>>> SECURE_PROXY_SSL_HEADER ('HTTP_X_FORWARDED_PROTO', 'https')
>>>>> #HTTPS stuff - secure cookies
>>>>> SESSION_COOKIE_SECURE True
>>>>> CSRF_COOKIE_SECURE True
>>>>>
>>>>> #HTTPS WSGI
>>>>> os.environ['wsgi.url_scheme'] 'https'
>>>>>>>>>>>> When I run Django/mod_wsgi/Apache on port 80 (same config as below, minus the mod_ssl stuff) or use the django development runserver
0.0.0.0:80, and disable the following settings in settings.py (#SESSION_COOKIE_SECURE True #CSRF_COOKIE_SECURE True) these browsers work correctly in the app.
>>>>>>>>>>>>
>>>>>>>>>>>> However, when running Django application running through mod_wsgi and HTTPS/port 443 in Apache, I see problems with both IE and Safari browsers. After login on Internet Explorer, page timeouts occur in various locations, reporting "This page can't be displayed". On Safari, the app won't get past the secondary Duo MFA authentication step, saying "Server unexpectedly dropped the connection." It is not a consistent behavior - seems to happen more frequently if I click quickly through links. Sometimes if I wait long enough to click, it might work momentarily, but then not again a moment later. This behavior does NOT happen using Chrome or Firefox browsers on any OS.
>>>>>>>>>>>>
>>>>>>>>>>>> Apache config:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> <IfModule mod_ssl.c>
>>>>>>>>>>>>
>>>>>>>>>>>> <VirtualHost *:443>
>>>>>>>>>>>>
>>>>>>>>>>>> ServerName **redacted**
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> #Django WSGI - Daemon
>>>>>>>>>>>>
>>>>>>>>>>>> WSGIScriptAlias / /var/www/transfergateway/myproject/apache/wsgi.py
>>>>>>>>>>>>
>>>>>>>>>>>> WSGIProcessGroup file-xfer
>>>>>>>>>>>>
>>>>>>>>>>>> WSGIDaemonProcess file-xfer user=mod_wsgi group=mod_wsgi processes=2 threads% python-path=/var/www/transfergateway