1

I am using a fileuploadfield component to upload a file from browser to a NGINX server. File size is 3Gb. NGINX version is 1.12.0. I have the following NGINX config:

http {
 server {

   listen      443;
   server_name SERVER_NAME_OR_IP;

   access_log  /var/log/nginx/access.log;
   error_log  /var/log/nginx/error.log  debug;

   ssl                  on;
   ssl_certificate      /path/to/cert.crt;
   ssl_certificate_key  /path/to/cert.key;
   ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;

   location ~* /test/abcd/ {
     client_max_body_size 3075m;
     proxy_pass http://127.0.0.1:7000;
     proxy_set_header        Host            $http_host;
     proxy_set_header        X-Real-IP       $remote_address;
     proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

  }
 }

 server {
  listen       127.0.0.1:7000;
  server_name  SERVER_NAME_OR_IP;
  client_max_body_size 3075m;
  location / {

      location ~ \.php$ {
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $request_filename;
         fastcgi_param   PHP_VALUE "upload_max_filesize = 3075M \n 
  post_max_size=3075M";
        include        /etc/nginx/fastcgi_params;
 }
}

}

The problem is that sometimes(it doesn't reproduce 100%), when I upload a 3Gb file, the nginx server writes partially the file in /tmp/ (it doesn't write a file with 3Gb size and every time it is a different size). After a while, in browser I get the error: 504 Gateway timeout and in PHP: upload failed with error 3. Do you know what might be the problem?

Thank you!

ioana
  • 21
  • 3
  • what is the output of the command (assuming unix) `php -i | grep upload_max_filesize` ? – Kyrre Sep 26 '17 at 13:22
  • The upload_max_filesize is 3075m – ioana Sep 26 '17 at 13:28
  • Just saw that in the supplied config as well. Was hoping for a quick fix, but that should be sufficient.. These might not be relevant either, but two other php.ini vars that affect uploads are `post_max_size` and `memory_limit`. It is possible that these are set too low. There might be some help to be found here: https://stackoverflow.com/questions/16102809/how-to-upload-large-files-above-500mb-in-php Good luck! – Kyrre Sep 26 '17 at 13:32
  • Those variables are set ok . I don t think that this is the problem, especially because sometimes it is working ok. But thank you for your answer. – ioana Sep 26 '17 at 14:26
  • You should be using chunk upload for this and not one big upload. See https://github.com/blueimp/jQuery-File-Upload/wiki/Uploading-to-nginx-using-the-nginx-upload-module and https://blog.martinfjordvald.com/2010/08/file-uploading-with-php-and-nginx/ – Tarun Lalwani Sep 26 '17 at 17:11
  • Thank you for your answer! Those links helped me to resolve my problem. – ioana Sep 27 '17 at 16:14

0 Answers0