I have a Django website where some of the URLs need to be served over HTTPS and some over a normal connection.
It's running on Apache and using WSGI. Here's the config:
<VirtualHost example.org:80>
ServerName example.org
DocumentRoot /var/www/html/mysite
WSGIDaemonProcess mysite
WSGIProcessGroup mysite
WSGIScriptAlias / /path/to/mysite/conferencemanager.wsgi
</VirtualHost>
<VirtualHost *:443>
ServerName example.org
DocumentRoot /var/www/html/mysite
WSGIProcessGroup mysite
SSLEngine on
SSLCertificateFile /etc/httpd/certs/aace.org.crt
SSLCertificateKeyFile /etc/httpd/certs/aace.org.key
SSLCertificateChainFile /etc/httpd/certs/gd_bundle.crt
WSGIScriptAlias / /path/to/mysite/conferencemanager_secure.wsgi
</VirtualHost>
When I restart the server, the first site that gets called -- https or http -- appears to select which WSGI script alias gets used.
I just need a few settings to be different for the secure server, which is why I'm using a different WSGI script. Alternatively, it there's a way to change settings in the settings.py file based on whether the connection is secure or not, that would also work.
Thanks
Elaboration:
The reason I want different settings is because I'm using a media server on the non-secure site:
MEDIA_URL = 'http://xmpl.org/media/'
STATIC_URL = 'http://xmpl.org/static/'
However, for the secure version rather than setting up another SSL certificate just for my media, I'm using the same server:
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
So I need the values to change at the settings level. I suppose if necessary I can write a context processor that overrides the values for STATIC_URL and MEDIA_URL if the server is secure.