uWSGI vhost问题

时间:2011-02-19 00:34:02

标签: python nginx wsgi uwsgi

uWSGI config

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

Nginx配置

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;
    }
}

无论我首先点击的是哪个站点都是显示的,所以如果我首先转到site2,我就看不到site1。有关为什么uWSGI vhost设置似乎不起作用的任何想法?

4 个答案:

答案 0 :(得分:5)

问题最终是使用INI配置文件导致uWSGI以单一解释器模式运行。 XML中完全相同的配置允许一切正常工作。 uWSGI开发人员在未来的版本中不会出现这种情况。

答案 1 :(得分:2)

此处http://wiki.nginx.org/HttpUwsgiModuleMultipleDynamicApplications您可以找到示例,如何通过单个上游设置多个uWSGI应用。

答案 2 :(得分:0)

如果你想使用TCP连接或者建立nginx,那就是uwsgi_pass支持:

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文件:

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

答案 3 :(得分:-1)

如何使用TCP套接字呢?

[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;
    }
}