Heim  >  Artikel  >  Backend-Entwicklung  >  django+uwsgi+nginx - 错误:nginx:504 Gateway Time out

django+uwsgi+nginx - 错误:nginx:504 Gateway Time out

WBOY
WBOYOriginal
2016-08-08 09:29:431382Durchsuche

分析

504 Gateway Time out

原因是因为相关参数设置的不当,还是很容易解决的

nginx和uwsgi整合时有三个参数可以用于设置超时时间:


1.uwsgi_connect_timeout:

默认60秒,与uwsgi-server连接的超时时间,该值不能超过75秒.若在超时时间内未能成功连接则断开连接尝试

2.uwsgi_read_timeout:

默认60秒,nginx等待uwsgi进程发送响应数据的超时时间。若有需要长时间运行才能产生输出结果的uwsgi进程则需将此参数调高。若在错误日志文件中看到
upstream timed out需将此参数调高。若超过超时时间还未收到响应则nginx关闭连接

3.uwsgi_send_timeout:

默认60秒,nginx向uwsgi进程发送请求的超时时间。超时时间由两次写操作的时间间隔算,而非整个请求。若超过超时时间仍没写入动作则nginx关闭连接


另外:uwsgi自身还有一个参数harakiri,若每次请求需要花费超过该值的时间则放弃该请求处理相应的worker被收回


我的实例:

uwsgi.ini

nginx.conf

xtyw_file.conf->location(此配置通过nginx.conf里的include导入生效)

以上就介绍了django+uwsgi+nginx - 错误:nginx:504 Gateway Time out,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn