2016-05-16 4 views
1

を使用してuWSGIで私のアプリケーションを提供しています。これはブラウザで127.0.0.1:3031に行くと動作します。私はNginxを使用したいので、私はそのURLにuwsgi_passに言ったが、今は502 Bad Gatewayのエラーが出る。どのようにNginxの背後にuWSGIを置くのですか?代わりにNginxの背後で動作するようにuWSGI HTTPサーバーを変換する

server { 
    listen 8080; 
    server_name 127.0.0.1; 

    location/{ 
     uwsgi_pass 127.0.0.1:3031; 
     include uwsgi_params; 
    } 

    location /static { 
     alias /static/folder/location; 
    } 
} 
2016/05/16 19:50:09 [error] 6810#0: *4 upstream prematurely closed 
connection while reading response header from upstream, client: 
127.0.0.1, server: 127.0.0.1, request: "GET/HTTP/1.1", upstream: 
"uwsgi://127.0.0.1:3031", host: "127.0.0.1:8080" 

答えて

0

使用socket、ないhttp-socket

uwsgi --socket 127.0.0.1:3031 -w app:app 

http-socketそれが直接uWSGIを理解しているので、HTTPを話すウェブサーバのようuWSGIの行為を行い、あなたがnginxのを使用している場合は正しくありません。

0

nginxとuWSGIの間でhttp-socketを使用できます。たとえば 、あなたがuWSGIとあなたのpythonのアプリを起動した場合:

uwsgi --http-socket 127.0.0.1:3031 --wsgi-file application.py --callable app --processes 4 --threads 2 --stats 127.0.0.1:9191 

設定nginxのと:

location/{ 
    proxy_pass http://127.0.0.1:3031/; 
} 
関連する問題