flask+uwsgi+nginx部署的时候nginx请求到不了uwsgi

发布于 2022-09-13 01:16:29 字数 1884 浏览 24 评论 0

uwsgi配置:

[uwsgi]
module = blog.app:app
master = true
processes = 4
http=127.0.0.1:8000
chdir = /home/saberbin/project/blog
socket = /home/saberbin/project/blog/myproject.sock

logto = /home/saberbin/project/blog/log/uwsgi.log
chmod-socket = 660
vacuum = true

nginx配置

server {
    listen 8080;
    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Connection "Keep-Alive";
        proxy_read_timeout 240s;
    }
}

测试的时候,访问uwsgi配置的8000端口可以正常访问,但是访问8080端口就返回504.
查了一下nginx的日志

2021/09/01 00:10:48 [error] 10662#10662: *13 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://127.0.0.1:8000", host: "127.0.0.1:8080", referrer: "http://127.0.0.1:8080/"
2021/09/01 00:11:41 [notice] 12862#12862: signal process started
2021/09/01 00:14:29 [error] 12863#12863: *20 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8000", host: "127.0.0.1:8080"
2021/09/01 00:17:39 [notice] 14288#14288: signal process started
2021/09/01 00:18:49 [error] 14289#14289: *22 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8000", host: "127.0.0.1:8080"
2021/09/01 10:00:56 [error] 28135#28135: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8000", host: "127.0.0.1:8080"

请问这个是什么原因呢,怎么解决这个问题?谢谢。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文