Choose another wsgi script based on subdomain in Apache?
Is it possible to change the wsgi script used by apache config based on the hostname of the request? I would like to set up a system where various wsgi applications can be deployed and then started, simply using a subdomain to automatically map to the correct wsgi script. Basically I try to avoid having to change the conf file every time another application is deployed.
<VirtualHost *:80>
ServerName mysite.us
ServerAlias *.mysite.us
WSGIDaemonProcess mysite
#can I use a different value here based on the domain?
WSGIScriptAlias / /home/ubuntu/mysite/wsgi.py
<Directory /home/ubuntu/mysite>
WSGIProcessGroup mysite
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
+3
source to share
1 answer
Have you tried setting the environment variable captured from the request uri and assigning the WSGIScriptAlias ​​path to that var?
Something like:
SetEnvIf HTTP_HOST "^(\w+).domain.tld" subdomain=$1
You may need to refine it a bit for your own purposes and you need apache2 to capture the regex values ​​with SetEnvIf.
http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html#setenvif
Then you should be able to use this:
WSGIScriptAlias / /home/ubuntu/mysite/%{subdomain}.wsgi.py
+1
source to share