サーバーにアップロードしたwebアプリが504を返すようになっちゃったときのメモ
環境
- nginx(1.26.0)
エラーログ
/var/log/nginx/error.log
upstream timed out (110: Connection timed out) while reading response header from upstream, "fastcgi://unix:/run/***",
cgiがタイムアウトしてる
タイムアウトまでの時間を延ばしてみる
/etc/nginx/nginx.conf
send_timeout 300;
keepalive_timeout 300;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
各パラメータの説明
send_timeout
- クライアントへのレスポンス送信にかかる最大時間
- デフォルト60秒
keepalive_timeout
- Keep-Alive接続のタイムアウトするまでの時間
- デフォルト75秒
- Keep-Aliveは、1回のTCP接続で複数のHTTPリクエストを処理する機能で、接続を再利用することでCPU負荷や時間を節約できる
fastcgi_connect_timeout
- FastCGIサーバーとの接続を確立するための最大時間
- デフォルト60秒
fastcgi_send_timeout
- FastCGIサーバーへのリクエストを送信する際の最大時間
- デフォルト60秒
fastcgi_read_timeout
- FastCGIサーバーからの応答を待つ最大時間
- デフォルト60秒
再起動
sudo systemctl restart nginx
表示できた
参考