ani*_*hek 36 configuration nginx connection-timeout uwsgi
我有Python Django应用程序的Nginx + uWSGI.
我有以下内容nginx.conf:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
uwsgi_read_timeout 1800;
uwsgi_send_timeout 300;
client_header_timeout 300;
proxy_read_timeout 300;
index index.html index.htm;
}
Run Code Online (Sandbox Code Playgroud)
但是对于uWSGI上长时间运行的请求大约需要1分钟才能完成,我在Nginx错误日志中会出现超时错误,如下所示:
2013/04/22 12:35:56 [错误] 2709#0:*1上游超时(110:连接超时)从上游读取响应头,客户端:xx.xx.xx.xx,server :, request :"GET/entity/datasenders/HTTP/1.1",上游:"uwsgi://127.0.0.1:9001",主机:"xxx.xx.xx.x"
我已经设置了标头超时和uWSGI发送/读取超时到5分钟,有人可以告诉我我能做些什么来克服这个问题?
ani*_*hek 65
解决问题的配置是:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
uwsgi_read_timeout 300;
index index.html index.htm;
}
Run Code Online (Sandbox Code Playgroud)
问题中的上述配置对我们不起作用的原因是因为遗憾的是在我们的机器中有多个路径有nginx.conf文件.我们正在以错误的方式处理conf.
要正确找出nginx从运行中获取配置的路径:
nginx -V # V is caps
Run Code Online (Sandbox Code Playgroud)
这将有一个--conf-path=[]会告诉你它从哪里获取配置.
我最近发现上面nginx -V没有给出正确的信息.我将留下上述内容以防万一其他人发现它有用.
通过更改以下 Nginx 配置解决
proxy_connect_timeout 300;
proxy_read_timeout 300;
client_body_timeout 300;
client_header_timeout 300;
keepalive_timeout 300;
Run Code Online (Sandbox Code Playgroud)
和UWSGI设置
http-timeout = 300 // or 'socket-timeout = 300' depending on uwsgi setting
Run Code Online (Sandbox Code Playgroud)