• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Image upload (resize) not working on nginx/php-fpm

#1
For some reason I can't upload large images on my nginx/php-fpm setup. The problem seems related to resolution and not just filesize. A 1000x1000px 10kb image does not work. Everything works fine in WordPress with the same setup.

Did anyone experience a similar problem?

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$uri&$args;
}

location ~ ^/(internal_data|library)/(.*)$ {
internal;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/fitnessbloggen/forum$fastcgi_script_name;
include fastcgi_params;

fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 128k;
fastcgi_buffer_size 128k;
fastcgi_buffers 16 128k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}

location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
 

Brogan

XenForo moderator
Staff member
#2
Presumably you've set the necessary limits in the ACP?

Why can't I upload an image, even though it is smaller than the maximum dimensions (pixels) permitted?
Server-side file size (KB) resizing is not supported. Any files which are larger than the maximum size specified in theACP -> Options -> Attachments: Maximum Attachment File Size (KB) will be rejected.

Why can I upload an image, even though it is larger than the maximum file size (KB) permitted?
Uploaded files are first resized based on the maximum physical dimensions (pixels) set in the ACP -> Options -> Attachments: Maximum Attachment Image Dimensions. If the resized image is below the maximum file size (KB) limit, then it will be allowed.

http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-180445
 
#3
Yup, not the problem. The uploader will simply stop at 100% and I get an error in the server log.

2011/08/31 23:05:47 [error] 24532#0: *423821 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 212.251.156.39, server: forum.fitnessbloggen.no, request: "POST /attachments/do-upload.json?hash=6b19c79fdc05b2a49087c57fc97718a3&content_type=post HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host:
 
#5
Tried setting
Code:
request_slowlog_timeout = 60
slowlog = /var/log/php-fpm-slow.log
The error still appears pretty much instantly, so I don't think its timing out

php-fpm.log (time not related to the upload)
[01-Sep-2011 18:34:13.517803] DEBUG: pid 22409, fpm_got_signal(), line 75: received SIGCHLD
[01-Sep-2011 18:34:13.517849] WARNING: pid 22409, fpm_children_bury(), line 249: [pool fitnessbloggen] child 22427 exited on signal 11 (SIGSEGV) after 41.521250 seconds from start
 

Luke F

Well-known member
#6
Code:
fastcgi_pass_request_body off;
client_body_in_file_only clean;
fastcgi_param  REQUEST_BODY_FILE  $request_body_file;
With this nginx will handle the uploads, then pass the completed upload to PHP-FPM. Works great here :)
 
#12
yea but we're spawning new processes for every user with open_basedir for a bit of extra security. I'm sure it can be turned back in a reasonable amout of time
 
#14
We switched it to the nobody user with the configuration above, but still get the same segfault from php-fpm. So the new config is working, but it's still crashing.
 

Mike

XenForo developer
Staff member
#15
I wonder if it's just plain PHP crashing, perhaps due to a memory issue? All I can really think of. 1000x1000 isn't a particularly large image though. Just to confirm, can you try the non-flash uploader? Additionally, if you disable JavaScript in your browser, it may give you some more info (though I suppose if PHP is crashing, we're not going to get any info from it...).