I have two mod_wsgi django sites and four domain names. Two domains point to each site. When I visit my two sites using all four domains in chrome, they all work fine. But only most of the time. Sometimes, given a domain, the wrong site is suddenly displayed. Completely out of the blue.
This is becoming very confusing because the behavior is completely unpredictable. I follow some internal links on site A, and all of a sudden, a 404 error from site B appears (naturally, the url couldn't be resolved in siteB's url's because it's a url from site A). I could refresh the page without changing the url and suddenly it would bring back site A. Or it would stay in the wrong site and 404 again, you just never know.
I've tried it on proxies (such as hidemyass.com) and the same unpredictable results happen.
The only predictability about it is that after apachectl -k graceful, there is no site switching for a while, but afterwards, it just happens every two pages. I assure you this was no bias.
Here's my httpd:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.siteA.tk
ServerAlias siteA.tk
WSGIScriptAlias / /home/me/siteA/siteA/wsgi.py
Alias /static/ /var/www/siteA/static/
</VirtualHost>
<VirtualHost *:80>
ServerName www.siteA.com
ServerAlias siteA.com
WSGIScriptAlias / /home/me/siteA/siteA/wsgi.py
Alias /static/ /var/www/siteA/static/
</VirtualHost>
<VirtualHost *:80>
ServerName www.siteB.tk
ServerAlias siteB.tk
WSGIScriptAlias / /home/me/siteB/siteB/wsgi.py
</VirtualHost>
<VirtualHost *:80>
ServerName www.siteB.com
ServerAlias siteB.com
WSGIScriptAlias / /home/me/siteB/siteB/wsgi.py
</VirtualHost>
<Directory /var/www/siteA/static>
Order deny,allow
Allow from all
</Directory>
WSGIPythonPath /home/me/siteA:/home/me/siteB
Please help, I am so scared, it's like my computer's possessed by some Apache demon.
Go read:
This describes all the common reasons why you can get mixing of responses for sites when running Django under Apache/mod_wsgi.
In addition to that, you can also see issues if not careful where you have sites sharing a common parent domain. For this you may have to adjust cookie domains or names if each site was setup and is effectively sharing the same cookie.
Also be aware of sharing common backend services for all sites such as memcache as there can be contention as far as distinct sites use the same keys for data. For that setup things to use a distinct memcache key prefix to keep data separate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With