django requests get mixed up?
I have 3 django projects with different settings, 2 under the subdomains parents.abc.com,teachers.abc.com and abc.com.
They all come under a shared apache instance. Here is my httpd configuration file:
LogFormat "%{X-Forwarded-For}i %l %u 开发者_C百科%t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/user/logs/user/access_django.log combined
ErrorLog /home/user/logs/user/error_django.log
KeepAlive Off
Listen 37049
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess django processes=5 python-path=/home/user/webapps/django:/home/user/webapps/django/lib/python2.6 threads=1
WSGIPythonPath /home/user/webapps/django:/home/user/webapps/django/lib/python2.6
NameVirtualHost *:37049
<VirtualHost *:37049>
WSGIScriptAlias / /home/user/webapps/django/abc.wsgi
ServerName abc.com
ServerAlias abc.com
</VirtualHost>
<VirtualHost *:37049>
WSGIScriptAlias / /home/user/webapps/django/parents.wsgi
ServerAlias parents.abc.com
</VirtualHost>
<VirtualHost *:37049>
WSGIScriptAlias / /home/user/webapps/django/teachers.wsgi
ServerAlias teachers.abc.com
</VirtualHost>
My problem comes (after a restart) if I visit parents.abc.com, followed by teachers.abc.com (or vice versa), I will encounter url error in the second because it seems like it is referencing the urls.py for the first project. i.e teachers.abc.com is looking at the settings file for parents.abc.com (vice versa).
Can anyone shed some light on this?
I think you need to specify the server name in each vhost
Add in:
ServerName parents.abc.com
and:
ServerName teachers.abc.com
ServerAlias, as far as I know, by itself is not enough to define a name based virtual host.
精彩评论