Gunicorn +烧瓶+ Nginx + WSGI错误502 Bad Gateway

时间:2019-09-20 21:37:00

标签: ubuntu nginx flask gunicorn wsgi

我尝试寻找答案,但是大多数人都遇到uwsgi而不是Gunicorn的错误。

nginx错误日志具有以下输出:

2019/09/20 17:23:20 [crit] 28847#28847: *2 connect() to unix:/home/ubuntu/app_test/app_test.sock failed (13: Permission denied) while connecting to upstream, client: <client-ip>, server: <server-ip>, request: "GET / HTTP/1.1", upstream: "http://unix:/home/ubuntu/app_test/app_test.sock:/", host: "<ip-address>"

我在nginx的{​​{1}}目录中具有以下应用程序的配置文件,并在sites-available中具有simlink:

sites-enabled

这是server { listen 80; server_name <server-ip>; location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/app_test/app_test.sock; } }

中的服务文件
/etc/systemd/system/app_test.service

(顺便说一句,为确定起见,我也尝试过使用掩码为[Unit] Description=Gunicorn instance to serve app_test After=network.target [Service] User=ubuntu Group=ubuntu WorkingDirectory=/home/ubuntu/app_test Environment="PATH=/home/ubuntu/app_test/appenv/bin" ExecStart=/home/ubuntu/app_test/appenv/bin/gunicorn --workers 3 --bind unix:app_test.sock -m 002 wsgi:app [Install] WantedBy=multi-user.target 的套接字文件。重新启动服务和007后,日志中的响应仍然相同。)

这是nginx文件:

app_test.py

最后,这是from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "<h1 style='color:blue'>Hello There!</h1>" if __name__ == "__main__": app.run(host='0.0.0.0')

wsgi.py

0 个答案:

没有答案