开发者

uWSGI vhost problem

uWSGI config

[uwsgi]
socket = /tmp/uwsgi.sock
chmod-socket = 666
processes = 1
master = true
vhost = true
no-site = true

Nginx config

server {
    listen       80;
    server_name  www.site1.com;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site1;
        uwsgi_param UWSGI_CHDIR /var/www/site1;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

server {
    listen       80;
    server_name  www.site2.com;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site2;
        uwsgi_param UWSGI_CHDIR /var/www/site2;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

Whatever site I hit first is the one 开发者_运维百科it is stuck displaying, so if I goto site2 first I can't ever see site1. Any thoughts on why the uWSGI vhost setting seems not to be workin?


The problem ending up being that using an INI config file results in uWSGI running in single interpreter mode. The exact same config in XML allows everything to work correctly. The uWSGI developer this would NOT be the case in future versions.


Here http://wiki.nginx.org/HttpUwsgiModuleMultipleDynamicApplications you can find example, how to setup multiple uWSGI apps, throuth a single upstream.


If you want to use TCP connection or nginx is built witout uwsgi_pass support:

nginx config:

location / {
    proxy_pass http://127.0.0.1:8010/;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

uwsgi ini file:

[uwsgi]
# set the http port
http = :8010


How about use TCP socket instead?

[uwsgi]
socket = 127.0.0.1:3031
processes = 1
master = true
vhost = true
no-site = true

nginx config

server {
    listen       80;
    server_name  www.site1.com;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site1;
        uwsgi_param UWSGI_CHDIR /var/www/site1;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

server {
    listen       80;
    server_name  www.site2.com;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site2;
        uwsgi_param UWSGI_CHDIR /var/www/site2;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜