# Mongrel upload progress and nginx

**URL:** <https://www.ruby-forum.com/t/mongrel-upload-progress-and-nginx/75872>\
**Category:** Rails\
**Created:** [November 13, 2006, 11:17pm UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-and-nginx/75872 "2006-11-13T23:17:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wmerydith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ccd318/32.png) [@wmerydith](https://www.ruby-forum.com/u/wmerydith)\
**Post date:** [November 13, 2006, 11:17pm UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-and-nginx/75872/1 "2006-11-13T23:17:06Z")

</div>

I can get the mongrel upload progress plugin to work for my app if I run  
my mongrel\_cluster behind pound, but it won’t work behind nginx. Is  
anyone using nginx as a mongrel frontend with upload progress meters  
successfully?  
thanks,

---

<div class="post-metadata">

**Author:** ![wmerydith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ccd318/32.png) [@wmerydith](https://www.ruby-forum.com/u/wmerydith)\
**Post date:** [November 13, 2006, 11:26pm UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-and-nginx/75872/2 "2006-11-13T23:26:58Z")

</div>

Will,

Haven’t tried it, but it is possible that Pound is routing the  
successive  
requests from each user back to the same mongrel process. This is  
important  
because each mongrel only knows about it’s own set of uploads unless you  
are  
using the DRb version of mongrel\_upload\_progress to synchronize all of  
your  
mongrels. I’m using the uploader behind Pen with the DRb synchro version  
and  
it works just fine. Pen is capable of trying to remember which user  
belongs  
to which backend server, but I’m not using that functionality and am  
opting  
for DRb to do the sync instead.

Check out the DRb section on:  
[http://mongrel.rubyforge.org/docs/upload\_progress.html](http://mongrel.rubyforge.org/docs/upload_progress.html)

Hope this helps…

Matt

On 11/14/06, Will M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
Thermal Creative  
[http://blog.thermalcreative.com](http://blog.thermalcreative.com)

---

<div class="post-metadata">

**Author:** ![wmerydith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ccd318/32.png) [@wmerydith](https://www.ruby-forum.com/u/wmerydith)\
**Post date:** [November 13, 2006, 11:47pm UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-and-nginx/75872/3 "2006-11-13T23:47:06Z")

</div>

Thanks for the reply – I should have mentioned that I am using DRb to  
handle the uploads as detailed at  
[http://mongrel.rubyforge.org/docs/upload\_progress.html](http://mongrel.rubyforge.org/docs/upload_progress.html) .

If I am using pound I can see the uploads with irb -r  
lib/upload\_client.rb , but cannot if I am using nginx.

Matt W. wrote:

> Will,
> 
> Haven’t tried it, but it is possible that Pound is routing the  
> successive  
> requests from each user back to the same mongrel process. This is  
> important  
> because each mongrel only knows about it’s own set of uploads unless you  
> are  
> using the DRb version of mongrel\_upload\_progress to synchronize all of  
> your  
> mongrels. I’m using the uploader behind Pen with the DRb synchro version  
> and  
> it works just fine. Pen is capable of trying to remember which user  
> belongs  
> to which backend server, but I’m not using that functionality and am  
> opting  
> for DRb to do the sync instead.
> 
> Check out the DRb section on:  
> [http://mongrel.rubyforge.org/docs/upload\_progress.html](http://mongrel.rubyforge.org/docs/upload_progress.html)
> 
> Hope this helps…
> 
> Matt
> 
> On 11/14/06, Will M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > >
> 
> –  
> Thermal Creative  
> [http://blog.thermalcreative.com](http://blog.thermalcreative.com)

---

<div class="post-metadata">

**Author:** ![wmerydith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ccd318/32.png) [@wmerydith](https://www.ruby-forum.com/u/wmerydith)\
**Post date:** [November 14, 2006, 12:09am UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-and-nginx/75872/4 "2006-11-14T00:09:08Z")

</div>

Will,

Shoot… I was hoping for simple 😉

Did a bit of sleuthing, and confirmed my suspicions about NGINX:  
[http://wiki.codemongers.com/NginxHttpProxyModule](http://wiki.codemongers.com/NginxHttpProxyModule)

Looks like it buffers the whole request in memory before passing it to  
the  
backend when you use it as a proxy:

“Note that when using the HTTP Proxy Module (or even when using  
FastCGI),  
the entire client request will be buffered in nginx before being passed  
on  
to the backend proxied servers. As a result, upload progress meters will  
not  
function correctly if they work by measuring the data received by the  
backend servers.”

Doh! Ezra beat me to it!

On 11/14/06, Will M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Matt W. wrote:
> 
> > mongrels. I’m using the uploader behind Pen with the DRb synchro version  
> > Hope this helps…  
> > Thermal Creative  
> > [http://blog.thermalcreative.com](http://blog.thermalcreative.com)
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Thermal Creative  
[http://blog.thermalcreative.com](http://blog.thermalcreative.com)

---

<div class="post-metadata">

**Author:** ![wmerydith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ccd318/32.png) [@wmerydith](https://www.ruby-forum.com/u/wmerydith)\
**Post date:** [November 14, 2006, 12:05am UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-and-nginx/75872/5 "2006-11-14T00:05:07Z")

</div>

On Nov 13, 2006, at 2:17 PM, Will M. wrote:

> I can get the mongrel upload progress plugin to work for my app if  
> I run  
> my mongrel\_cluster behind pound, but it won’t work behind nginx. Is  
> anyone using nginx as a mongrel frontend with upload progress meters  
> successfully?  
> thanks,

Hey Will-

```
Unfortunately nginx doesn't work with the mup right now. Nginx

```

always buffers the upload to disk before passing it to mongrel. So by  
the time mongrel getr notified, the entire upload has already taken  
place. The author of nginx is aware of this and is going to either  
allow pass thru uploads or implement an nginx upload\_progress module.

```
For now you have to use another form of load balancer to send upload

```

requests directly to mongrel. Since the file upload happens in an  
iframe, the trick I have used is to run one mongrel on a higher port  
to handle the uploads. Since it gets used in an iframe the user won’t  
ever see the port number. And if you need ti to work through  
firewalls and you arent using ssl you can run the upload mongrel on  
port 443 instead of ssl. That way no firewalls block it. Then that  
mongrel just redirects to the normal mongrels to finish up the upload.

```
Nginx gets updated very often. So I hope there will be a way to do

```

this with nginx very soon.

Cheers-  
– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)
