为什么我在通过 nginx 和 uwsgi 提供 flask 应用程序时会收到 110:连接超时错误?

为什么我在通过 nginx 和 uwsgi 提供 flask 应用程序时会收到 110:连接超时错误?

我正在尝试通过 ubuntu docker 容器使用 nginx 和 uwsgi 提供 flask 应用程序,而主机也是 ubuntu 18.04 操作系统。

这是 nginx 服务器的 conf 文件,我为其创建了一个符号链接/etc/nginx/sites-enabled

server {
    listen 1611;
    real_ip_header X-Forwarded-For;
    set_real_ip_from 127.0.0.1;
    server_name localhost;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/html/step_service/socket.sock;
        uwsgi_modifier1 30;    
    }
}

`uwsgi.ini'文件如下:

[uwsgi]
base=/var/www/html/step_service
app=app
module=%(app)
callable = app

home=%(base)/venv
pythonpath=%(base)
socket=%(base)/socket.sock
chmod-socket=777

master=true
processes=5
threads=5
die-on-term=true
autostart=true
autorestart=true
harakiri=30
logto=/var/www/html/step_service/log/%n.log

uwsgi 的日志似乎表明成功:

 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

nginx 服务器的日志(特别是error.log)是:

2019/04/18 16:23:30 [error] 6729#6729: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.17.0.1, server: localhost, request: "GET /rec/1/1 HTTP/1.1
", upstream: "uwsgi://unix:/var/www/html/step_service/socket.sock", host: "172.17.0.2:1611"

任何想法都值得欢迎!

相关内容