Welcome! Log In Create A New Profile

Advanced

nginx 500 error when file 99% uploaded

Posted by o-dog 
nginx 500 error when file 99% uploaded
April 18, 2016 01:41PM
Dear all, I am using nginx/1.8.0 and to debug a large file upload issue I am facing in WordPress, I post a file with a simple script:

Index file:

<html>
<!-- index.html -->
<head></head>
<body>
<form action="do.php" method="post" enctype="multipart/form-data" name="form">
<label>File:</label><br/><br/>
<input type="file" name="uploaded" required><br/><br/>
<input type="submit" value="Upload">
</form>
</body>
</html>

And php code below:

<?php
// this code lives in do.php
$file = $_FILES['uploaded']['tmp_name'];
$image = addslashes(file_get_contents($_FILES['uploaded']['tmp_name']));
$image_name = addslashes($_FILES['uploaded']['name']);
move_uploaded_file($_FILES["uploaded"]["tmp_name"], "uploads/" . $_FILES["uploaded"]["name"]);\
echo( $_FILES["uploaded"]["name"] );
?>

I am not seeing anything in the error logs, just returned in Chrome headers for `http://example.com/do.php` `Code:500 Internal Server Error`

This seems to happen when nginx has 99% finished uploading a file (anything under 100MB seems OK) I can track the upload progress in the temp directory:

root@www:/home/example/logs# ll -h /var/lib/nginx/
total 28K
drwxr-xr-x 7 root root 4.0K Feb 4 14:32 ./
drwxr-xr-x 42 root root 4.0K Feb 5 06:26 ../
drwx------ 2 www-data root 4.0K Apr 18 20:46 body/
drwx------ 12 www-data root 4.0K Feb 4 17:19 fastcgi/
drwx------ 2 www-data root 4.0K Feb 4 14:32 proxy/
drwx------ 2 www-data root 4.0K Feb 4 14:32 scgi/
drwx------ 2 www-data root 4.0K Feb 4 14:32 uwsgi/

root@www:/home/example/logs# ll -h /var/lib/nginx/body/
total 103M
drwx------ 2 www-data root 4.0K Apr 18 20:46 ./
drwxr-xr-x 7 root root 4.0K Feb 4 14:32 ../
-rw------- 1 www-data www-data 103M Apr 18 20:47 0000000239

I have even set the `/var/lib/nginx` to `chown www-data:www-data` but still get the same error.

I have put in `http`, `server`, `location` sections the following, but again does not make a difference:

client_body_in_file_only clean;
client_body_buffer_size 32k;
client_max_body_size 300M;
send_timeout 900s;
proxy_connect_timeout 900s;
proxy_send_timeout 900s;
proxy_read_timeout 900s;
fastcgi_send_timeout 900s;
fastcgi_read_timeout 900s;
fastcgi_buffer_size 64k;
fastcgi_buffers 32 32k;

I am using php5-fpm, and all matching similair upload and max-memory settings to match nginx equivalents but this seems to be coming from nginx as i cant see any errors anywhere (any reason this is not logged)?

Any ideas please, I am ripping my hair out!?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 200
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready