| 场景 | 经 Nginx/SLB 后访问异常或变慢 |
|---|---|
| 工具 | nginx access/error log、curl 对照直连与经代理 |
| 关键字段 | $request_time、$upstream_status、$upstream_response_time |
对照与取证
对照与取证
curl -sS -o /dev/null -w 'direct %{http_code} %{time_total}\n' http://127.0.0.1:8080/api/health
curl -sS -o /dev/null -w 'proxy %{http_code} %{time_total}\n' -H 'Host: api.example.com' http://10.0.0.5/api/health
tail -50 /var/log/nginx/error.log
grep 'upstream' /var/log/nginx/error.log | tail -20日志里没有 $upstream_response_time 就先补上再复现:有了它,『代理自身慢』与『后端慢』一眼可分。