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

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"

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

阅读 1.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏