2011-02-19 225 views
6

uWSGI配置uWSGI虛擬主機問題

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

我打了不管網站首先是一個還停留顯示,所以如果我轉到站點2第一我無法看到的SITE1 。任何想法爲什麼uWSGI虛擬主機設置似乎不工作?

回答

5

結束了處在於使用uWSGI的INI配置文件,導致單個解釋模式下運行的問題。 XML中的完全相同的配置允許一切正常工作。 uWSGI開發者在未來的版本中不會這樣。

-1

如何使用TCP套接字來代替?

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

nginx的配置

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

如果您想使用TCP連接或nginx的內置不用其他uwsgi_pass支持:

nginx的配置:

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