uWSGI VirtualHosting Mode
By default you can run multiple apps in the same process using different SCRIPT_NAME vars or with uwsgi protocol modifiers.
WARNING this operational mode is for hosting a minimal amount of sites, it is a very complex way of doing thing and highly insecure if you do not trust your apps. The best way for hosting multiple apps in a secure way is having one instace per application (you can use the Emperor for managing multiple instances)
From version 0.9.6 you can use the SERVER_NAME var to load multiple apps.
This is the VirtualHosting mode, to enable it simply add the --vhost option to the command line (or xml or environment vars)
./uwsgi -s :3031 -M -p 4 --vhost
Dynamic apps
You can use VirtualHosting mode with DynamicApps
server {
listen 8080;
server_name localhost;
location / {
uwsgi_pass 192.168.173.5:3031;
include uwsgi_params;
uwsgi_param UWSGI_SCRIPT mymako;
uwsgi_param UWSGI_PYHOME /Users/roberto/uwsgi/VENV1;
}
}
server {
listen 8080;
server_name mrspurr.local;
location / {
uwsgi_pass 192.168.173.5:3031;
include uwsgi_params;
uwsgi_param UWSGI_SCRIPT mytrac;
uwsgi_param UWSGI_PYHOME /Users/roberto/uwsgi/VENV2;
}
location /arm {
uwsgi_pass 192.168.173.14:3031;
include uwsgi_params;
}
}
As we want to use DynamicVirtualenv we will add the --no-site option to uWSGI
./uwsgi -s :3031 -M -p 4 --vhost --no-site
Static apps
You can use you uwsgi entrypoint module to define virtualhosts:
import uwsgi
def app1(env, start_response):
...
def app2(env, start_response):
...
uwsgi.applications = {'unbit.it|': app1, 'localhost|/ciao': app2}
The syntax is the same as SCRIPT_NAME only configurations, you have to simply add the domain name to the dictionary key (using a pipe to split it from the SCRIPT_NAME)
