[英]How to increase timeout for NGINX?
我正在使用 Python、Flask、uWSGI 和 NGINX 来托管 Web 服务器。 其中一个功能涉及为用户生成一个文件,这可能需要一两分钟。 在此操作中,我不断收到来自 NGINX 的 504 超时。 我尝试更改/etc/nginx/nginx.conf
一些配置变量,例如keepalive_timeout
但这不起作用。我还尝试将以下内容添加到/etc/nginx/conf.d/timeout.conf
:
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
然后我用systemctl reload nginx
重新加载,但它没有改变任何东西。
如何增加请求超时前的时间长度? 谢谢你的帮助
在“http”部分的末尾添加以下指令以将超时限制增加到 180 秒(3 分钟):
http {
<...>
include /etc/nginx/conf.d/.conf;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
fastcgi_send_timeout 180s;
fastcgi_read_timeout 180s;
}
来源: https : //support.plesk.com/hc/en-us/articles/115000170354-An-operation-or-a-script-that-takes-more-than-60-seconds-to-complete-fails- on-a-website-hosted-in-Plesk-nginx-504-Gateway-Time-out
我遇到了同样的问题..我找到了一种解决方法,告诉 nginx 接受一定数量的数据而不是默认数据。 不是试图管理超时本身,而是改变事务中接受的数据量就成功了。
server {
client_max_body_size 5M; # or more ^^
}
但它真的不是一个安全的选择......它有效,但要小心这样做。
此外,如果您使用反向代理 WSGI 网关(例如 Php).. 底层机制可能优先于那个
server {
server_name yourhost;
client_max_body_size 5M;
location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080; # depending on your network conf
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.