0

Djangoプロジェクトが1つしかない場合は全体がうまく機能しますが、別のDjangoプロジェクトを作成し、前のものでnginxに追加したい場合、1つだけが機能し、もう1つは502エラーを示します.

nginx 構成:

server{
listen 80;
root /root/www;
server_name 119.254.35.221;
location /{
uwsgi_pass 127.0.0.1:8000;
include uwsgi_params;
uwsgi_param UWSGI_SCRIPT www.wsgi;
uwsgi_param UWSGI_CHDIR /root/www;
uwsgi_param UWSGI_PYHOME /root/www;
uwsgi_param SCRIPT_NAME "";
}
}

server{  
    listen 81;
    root /root/www1;
    server_name 119.254.35.221;      
    location / {  
        uwsgi_pass 127.0.0.1:8000;  
        include uwsgi_params; 
        uwsgi_param UWSGI_SCRIPT www1.wsgi;
        uwsgi_param UWSGI_CHDIR /root/www1;
        uwsgi_param UWSGI_PYHOME /root/www1;
        uwsgi_param SCRIPT_NAME "";
    }  
}

uwsgi.ini:

[uwsgi]  
uid = 500
listen=200
master = true  
profiler = true 
processes = 8 
logdate = true  
socket = 127.0.0.1:8000  
pidfile = /root/www/www.pid  
daemonize = /root/www/www.log  
enable-threads = true
memory-report = true
limit-as = 6048

And I create two project: 
1, www: django-admin.py startproject www 
2, www1: django-admin.py startproject www1

Then I start nginx and uwsgi: 
1, ngxin 
2, uwsgi --ini uwsgi.ini --vhost

最後に、119.254.35.221:80 と 119.254.35.221:81 にアクセスしましたが、そのうちの 1 つ (ポート 80 または 81 の可能性があります) のみが正常に機能し、もう 1 つは ERROR:502 を示します。

助けて、私は狂ってしまう..

server {
    listen   80;
    server_name customersite1.com www.customersite1.com;
    access_log /var/log/customersite1/access_log;
    location / {
                root   /var/www/customersite1
        uwsgi_pass 127.0.0.1:3031;
        include        uwsgi_params;
    }
}

server {
    listen   80;
    server_name customersite2.com www.customersite2.com;
    access_log /var/log/customersite2/access_log;
    location / {
                root   /var/www/customersite2
        uwsgi_pass 127.0.0.1:3032;
        include        uwsgi_params;
    }
}

server {
    listen   80;
    server_name pippo.com;
    access_log /var/log/pippo/access_log;
    location / {
                root   /var/www/pippohome
        uwsgi_pass 127.0.0.1:3033;
        include        uwsgi_params;
    }
}
Now you have to run the customer's applications (you can use rc.local or upstart or whetever you want) with a different uid and a limited (if you want) address space for each socket:

uwsgi --uid 1001 -w customer1app --limit-as 128 -p 3 -M -s 127.0.0.1:3031
uwsgi --uid 1002 -w customer2app --limit-as 128 -p 3 -M -s 127.0.0.1:3032
uwsgi --uid 1003 -w django3app --limit-as 96 -p 6 -M -s 127.0.0.1:3033

これを解決するために公式の方法に従っていますが、ここで回避策はありますか?

4

1 に答える 1

0

同じ uWSGI プロセスで複数のアプリをホストすることは、(セキュリティと構成の容易さの観点から) 最善の方法ではありません。複数の uWSGI インスタンス (アプリ用に 1 つ) を持つことは、uWSGI Emperor と組み合わせてそれらを管理するための最良のソリューションです。

ちなみに、複数のインタープリターを使用したい場合は、オプションに -vhost-host を追加する必要があるかもしれません。仮想ホスト キーは SERVER_NAME ではなく HTTP_HOST にする必要があるためです (この変数ではポートが指定されていないため)。

于 2012-09-28T14:35:33.800 に答える