nginx - Nginx 上的 Flask 应用程序 1 分钟后超时

标签 nginx flask uwsgi

我正在尝试通过 uWSGI 在 Nginx 上提供 Flask 应用程序(第一次使用 Nginx for Flask)。

Nginx 配置如下:

server {

    listen 80;

    location / {
        include uwsgi_params;
        uwsgi_pass flask:5555;
    }

    client_max_body_size 100M;

    client_header_timeout 120s;
    client_body_timeout 120s;
    keepalive_timeout 120s;
    send_timeout 120s;
}

和uWSGI

wsgi-file = run.py
callable = app
socket = :5555
processes = 4
threads = 2
master = true
chmod-socket = 660
vacuum = true
die-on-term = true

但是负载较大的 Flask 应用无论如何都会在 1 分钟后在 Nginx 端超时。

Flask 应用程序从终端运行时工作正常。

有什么建议吗?

最佳答案

解决了在 nginx.conf 中向 uWSGI 添加超时的问题

server {

    listen 80;

    location / {
        include uwsgi_params;
        uwsgi_pass flask:5555;
        uwsgi_read_timeout 300;
    }

    client_max_body_size 100M;

    client_header_timeout       120s;
    client_body_timeout         120s;
    keepalive_timeout           120s;
    send_timeout                120s;
}

关于nginx - Nginx 上的 Flask 应用程序 1 分钟后超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62543174/

相关文章:

azure - Azure上的Docker compose webapp无法访问

当 server_name 正则表达式不匹配时,nginx 接受尾随点

Docker 与 nginx 组合不断显示欢迎页面

ubuntu - Nginx 安装后未启动 [emerg] open() "/etc/nginx/nginx.conf"failed (2 : No such file

python - 修改 SqlAlchemy 模型时出现 Unhashable Type 错误

python - 如何在 python Flask 的新选项卡中打开响应

python - 如何在 nginx docker 和 uwsgi docker 之间共享 .sock 文件?

python - uWSGI虚拟主机问题

nginx - 戈兰 + nginx + https

django - nginx 不会在某些端口上响应