超时问题都是后台服务响应时间超出OpenResty的timeout的设置时间,OpenResty的默认超时时间为60s。可以通过测试上游服务得出最后的影响时间的具体值,如果是固定在某个区间内的,可以通过调整OpenResty的超时时间的设置来解决此类问题:
具体路径为/usr/local/openresty/nginx/conf/nginx.conf
-
proxy_connect_timeout 具体时间s;
# 作为反向代理时,转发请求超时。
-
proxy_send_timeout 具体时间s;
# 获取上游响应时超时。
-
proxy_read_timeout 具体时间s;