Reputation: 1970
I am trying to run 2 Django sites from one apache server using virtual hosts with mod_wsgi
. The problem is that all my request are going to the same Django site(probably the first one loaded by Apache) even when I use the hostname for the other site. My sites are
https://staging-test.mydomain.com
and
https://staging.mydomain.com
Here is the content of my virtual hosts files. I have created the two files for deployment which I place in the site-enabled
directory of my Apache installation(Ubuntu). Two files because it helps in dev-ops. Regardless, the config looks like
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName https://staging-test.mydomain.com
SetEnv PYTHON_EGG_CACHE /tmp
WSGIDaemonProcess https://staging-test.mydomain.com user=www-data group=www-data processes=10 threads=1 python-path=/home/talha/site1 display-name=wsgid
WSGIProcessGroup https://staging-test.mydomain.com
WSGIScriptAlias / /home/talha/site1/wsgi.py process-group=https://staging-test.mydomain.com application-group=%{RESOURCE}
WSGIPassAuthorization On
WSGIApplicationGroup %{RESOURCE}
</VirtualHost>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName https://staging.mydomain.com
SetEnv PYTHON_EGG_CACHE /tmp
WSGIDaemonProcess https://staging.mydomain.com user=www-data group=www-data processes=10 threads=1 python-path=/home/talha/site2 display-name=wsgid
WSGIProcessGroup https://staging.mydomain.com
WSGIScriptAlias / /home/talha/site2/wsgi.py process-group=https://staging.mydomain.com application-group=%{RESOURCE}
WSGIPassAuthorization On
WSGIApplicationGroup %{RESOURCE}
</VirtualHost>
I have tried to use the WSGIDaemonProcess
and WSGIProcessGroup
to make the sites run in different processes, however the requests are still going to only one of them.
Any ideas what might be wrong here?
Upvotes: 1
Views: 331
Reputation: 58563
As someone pointed out, your initial problem is that you should not use a URI in the ServerName, it must be just the host name. Beyond fixing that, then make sure you read:
You are hitting a variation of the default VirtualHost problem described in that post due to wrong setting for ServerName.
Upvotes: 1