當訪問一個接口出現這個錯誤時 504 Gateway Time-out , 說明是后端服務超時了 ,
504是gateway timeout 網關超時 , 如果fpm響應的太慢 , 超過了nginx里面配置的fastcgi_read_timeout 超時時間 , 就會出現這個錯誤
可以有以下處理流程
首先查看nginx的access日志 , 看看接口請求是否到達了
tail -f /var/log/nginx/xxxx-access.log
可以得知nginx部分已經到達
后端是php-fpm , 可以查看fpm的error日志
tail -f /var/log/php-fpm/www-error.log
基本可以知道在訪問某個ldap服務的時候 , 連接超時不可達了
用tcpdump也可以看到三次握手的第一步 SYN請求就沒有回應 , 也ping不通
tcpdump -i any host 10.210.97.21 -l -s 0
重新更改接口地址后就ok了
還有一種是502錯誤 , 出現502是因為下面的原因:
在fpm的配置php.ini配置文件中
max_execution_time
以及fpm的配置文件比如www.conf中
request_terminate_timeout
這里是php里面設置的超時時間 , 如果超過了這個時間會報502錯誤