502 Raspberry pi上的网关错误

时间:2018-11-29 19:54:38

标签: nginx flask raspberry-pi virtualenv uwsgi

我正在尝试使用uwsgi,nginx,flask和虚拟环境在树莓派上托管Web服务器。使用以下配置

myproject.ini

[uwsgi]
module = wsgi:app

master = true
processes = 5

socket = /tmp/myproject.sock
chmod-socket = 660
vacuum = true

die-on-term = true

myproject.py

from flask import Flask
app = Flask(__name__)

@app.route("/get/")
def hello():
    return "<h1 style='color:blue'>Hello There!</h1>"

if __name__ == "__main__":
    app.run(host='0.0.0.0')

wsgi.py

from myproject import app

if __name__ == "__main__":
    app.run()

nginx配置文件

(myprojectenv) shoaib@raspberrypi:/etc/nginx/sites-available $ cat myproject 

server {
    listen 80;
    server_name www.frasmd.com  frasmd.com 10.10.10.10;

    location / {
    proxy_request_buffering off;
    proxy_buffering off;
        include uwsgi_params;
        uwsgi_pass unix:/tmp/myproject.sock;
    }
}

当我启动服务时,我没有错误启动它们,但是当我在Chrome浏览器中提供url时,我得到了“ 502 Badgateway”。我尽了我所能找到的一切,但没有帮助。我在配置中缺少什么吗?

我的/var/log/nginx/error.log中出现以下错误

2018/11/30 00:42:28 [error] 4368#4368: *1 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: www.frasmd.com, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/tmp/myproject.sock:", host: "0.0.0.0", referrer: "http://0.0.0.0/get"
2018/11/30 00:43:15 [error] 4368#4368: *1 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: www.frasmd.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/tmp/myproject.sock:", host: "0.0.0.0"
2018/11/30 00:43:15 [error] 4368#4368: *1 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: www.frasmd.com, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/tmp/myproject.sock:", host: "0.0.0.0", referrer: "http://0.0.0.0/"

0 个答案:

没有答案