Reputation: 1745
We have a Django application served by Apache (mod-wsgi) with such config :
<VirtualHost vhost:80>
# ...
WSGIScriptAlias / /path/to/wsgi.py
</VirtualHost>
We're looking to serve that single application into 2 virtualhosts : vhost:80
and vhost:443
... the time necessary for the client's migration and finally only keep it on the https virtualhost.
Is it possible to duplicate the instruction WSGIScriptAlias / /path/to/wsgi.py
into a second virtualhost (vhost:443
) or will we encounter problems running twice the same app with same DB?
Upvotes: 0
Views: 389
Reputation: 58563
First up, you want to make sure you are using daemon mode of mod_wsgi and not embedded mode. Either way, if a multi process configuration was being used, you would already have multiple instances of the application accessing the same database. That is generally not an issue. The issue is doubling up on the number of processes when adding the virtual host for SSL. This is where daemon mode comes in. The typical configuration is:
<VirtualHost *:80>
ServerName sitename.example.com
# Define a daemon process group.
WSGIDaemonProcess sitename
# Specify WSGI application and delegate to daemon process group.
# As delegating here, don't need WSGIProcessGroup/WSGIApplicationGroup.
WSGIScriptAlias / /path/to/wsgi.py process-group=sitename application-group=%{GLOBAL}
# ... access control directives
</VirtualHost>
<VirtualHost *:443>
ServerName sitename.example.com
# ... SSL options
# Specify WSGI application and delegate to daemon process group.
# As delegating here, don't need WSGIProcessGroup/WSGIApplicationGroup.
#
# Note that we did not define a daemon process group in this virtual
# host. Instead we rely on fact that can reach across and use daemon
# process group defined in virtual host for port 80. This is possible
# as value of ServerName is the same.
WSGIScriptAlias / /path/to/wsgi.py process-group=sitename application-group=%{GLOBAL}
# ... access control directives
</VirtualHost>
Add process=nnn
and threads=nnn
options to WSGIDaemonProcess
if need to tune capacity and performance. Also ensure you revise timeout options you may want to set on daemon process group.
Upvotes: 1