###問題發生的背景:
合作方請求某個接口,由於處理時間較長,導致了網關超時.
###問題分析:
1.可能是php程序超時報錯;
2.php-fpm處理請求超時;
3.nginx服務器超時.
###問題解決:
1.php超時設置:
檢查了php超時的配置,在php.ini里面:max_execution_time, 配置為300s,結果還是一樣報了504超時.
2.查閱資料后,覺得可能是nginx代理超時,將nginx.conf或者vhost中的配置文件中加入設置的代理時長,結果還是沒起作用: proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; send_timeout 300s; 3.最后設置了fastcgi的超時配置,重啟nginx就可以了. fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; 如果以后再遇到超時504的錯誤,也可以按照這幾個參數進行配置.