Forum: NGINX Nginx handle of large uploads , proxy to cgi?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joe S. (Guest)
on 2008-11-23 00:07
(Received via mailing list)
Very weird issue.

I am testing nginx with PHPMOTION, but there is a problem.

Its being tested on:

http://phpmotion.aptget.com/

The problem is PHPMOTION sends the upload to a cgi script, which I
have set in nginx to proxy all cgi scripts to Apache itself using:

                location ~ \.cgi$ {
                        proxy_pass http://127.0.0.1:82;
                        proxy_redirect off;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
                }


Works great, cgi works great, but when its sending a large upload, I
ran an strace to the script uploading:

stat64("/home/phpmotio/public_html/temp/aaf1b8635490edaf34473de6e1cd849c/flength",
0xb7fdc900) = -1 ENOENT (No such file or directory)
time(NULL)                              = 1227391028
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, {1, 0})               = 0
time(NULL)                              = 1227391029
stat64("/home/phpmotio/public_html/temp/aaf1b8635490edaf34473de6e1cd849c/flength",
0xb7fdc900) = -1 ENOENT (No such file or directory)
time(NULL)                              = 1227391029
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, {1, 0})               = 0
time(NULL)                              = 1227391030
write(1, "Content-type: text/xml\n\n<?xml ve"..., 176) = 176
exit_group(0)                           = ?
Process 28593 detached

Which back to the user gets the error "ERROR: Failed to find flength
file" , because it couldn't find the above file, its there to show to
the user the upload progress bar.

But the weird thing is Nginx is still accepting the upload in the
background, so it is working, and it does everything else properly,
conversion, but nginx is the one taking over the upload.

Is there a setting I can do in nginx somewhere so when uploading to
via cgi, etc, to work properly as the script intended somehow?

Or is it simply that this won't work properly on Nginx?

Thanks!
Maxim D. (Guest)
on 2008-11-23 01:09
(Received via mailing list)
Hello!

On Sat, Nov 22, 2008 at 04:00:42PM -0600, Joe S. wrote:

[...]

>
> Or is it simply that this won't work properly on Nginx?

When processing user uploads nginx always buffers entire user
upload, and calls backend only when upload is complete.  There is
on way to change this behaviour.

To track uploads you have to use Brice F.'s upload progress
module, see http://wiki.codemongers.com/NginxHttpUploadProgressModule.

Maxim D.
This topic is locked and can not be replied to.