前言
现在线上系统的架构大致是这样的,除去cache的proxy机器外,还有项目的nginx proxy机器,后面跟nginx webserver + php-fpm。有时候,会看到proxy nginx的日志里面会有各种异常状态码,比如499,502,504等,这些都是什么情况导致的呢?
架构示意
nginx proxy => nginx webserver => php-fpm
状态码说明
499:客户端(或者proxy)主动断开连jie502:网关错误(Bad Gateway)504:网关超时:(Gateway Timeout)
一、proxy和webserver不能连接
1.1 proxy_pass ip不存在
这时候会重复发送arp解析协议,约3秒后超时,proxy返回码为502。
1.2 proxy_pass ip存在
webserver机器上端口上没有对应服务;
webserver所在机器的内核会直接返回RESET包,没有额外超时,proxy返回码为502。
webserver机器端口上有服务,但是iptables DROP了proxy的包;
因为webserver drop(iptables -I INPUT -s xxx.xxx.