问题
nginx访问出现504 Gateway Time-out
常见原因:程序在处理大量数据,接口超过1分钟(默认的)未返回数据,导致等待超时。
出现这种情况,我们可以先优化程序,缩短执行时间。可以调大nginx超时限制的参数,使程序可以正常执行。
解决方法
nginx配置nginx.conf中,设置以下几个参数,增加超时时间配置:
如果使用了Nginx的代理,可以在下面这里加上下面三个配置:
location /foo {
proxy_pass http://xxx.xxx.xxx.xxx:8080/foo;
proxy_connect_timeout 300s; # 默认60s
proxy_send_timeout 300s; # 默认60s
proxy_read_timeout 300s; # 默认60s
}