2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravel8 Nginx 504 Gateway Timeout エラーが出た

Last updated at Posted at 2021-12-21

目的

  • Postするファイルサイズの設定修正後にテストで大きいファイルをPostしてみたところ今度は「504 Gateway Timeout」のエラーが出たので解消する方法をメモ的にまとめる

経緯

どうしたいか

  • とにかく大きいファイルをPostできるようにしたい。(504エラーをとにかく回避したい。)

方法

  1. /etc/nginx/conf.d/default.confを修正して設定反映できるようになったので、default.confに下記の内容を記載する。(一旦タイムアウトのリミットを300秒まで引き上げる)

    /etc/nginx/conf.d/default.conf
    # ファイルアップロードのタイムアウト対策
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    send_timeout 300;
    keepalive_timeout 300;
    
  2. default.confファイル内は下記の様に記載されている。

    /etc/nginx/conf.d/default.conf
    server {
        listen 80;
        root  /var/www/html/public;
        index index.php index.html;
        # ファイルアップロードのために追記
        client_max_body_size 700M;
        # ファイルアップロードのタイムアウト対策
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        send_timeout 300;
        keepalive_timeout 300;
    
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }
    
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }
    
  3. php.iniに下記の記載を追記する。

    php.ini
    max_execution_time = 300
    
  4. 念の為dockerを再ビルドしてnginxを再起動したら5分弱で容量の大きなファイルをPostする事ができた。

  5. とりあえずPostできたが実用的な時間じゃないので色々試行錯誤が必要そう。

参考文献

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?