本文主要讲述一下nginx与tomcat的502、504、503错误及其常见的产生原因。
502 Bad Gateway : 作为网关或者代理工作的服务器尝试执行请求时,从上游服务器接收到无效的响应。
将后端服务关掉,然后向nginx发送请求后端接口,日志如下:
504:gateway timeout.作为网关或者代理工作的服务器尝试执行请求时,未能及时从上游服务器(URI标识出的服务器,例如HTTP、FTP、LDAP)或者辅助服务器(例如DNS)收到响应。注意:某些代理服务器在DNS查询超时时会返回400或者500错误
相对少见
)503表示service unavailable,表示服务器当前处于暂时不可用状态,无论是有意还是无意,当服务器端处于无法应答的状态时,就会返回该状态码。其中,服务端因维护需要而停止服务属于有意的情况。而当服务器自身负载过高,处于无法响应的状态时,则属于无意的情况。另外,负载均衡器或者web服务器的前置机等这些地方的服务器也有可能返回503.