Passing errors on to ruby on max upload

Jean-Philippe Moal skateinmars at skateinmars.net
Thu Oct 2 12:37:37 MSD 2008


Fred a écrit :
> Hello,
> I have a ruby application where users are able to upload a file of max size 1
> MB, which alerts users if the file they are trying to upload is over that size.
>  In my nginx configuration, I have set the max upload size set to 2 MB as per
> client_max_body_size
> (http://wiki.codemongers.com/NginxHttpCoreModule#client_max_body_size).
> 
> My problem is that when I upload a file that is larger 2 M, nginx gets the error
> (as seen in the logs) and nothing is passed to the ruby code, so in the
> application it just hangs, waiting to complete the upload.  
> 
> So the question is - is there any way to forward the error on to ruby at all or
> is there any way to work around this aside from changing the max upload size on
> the server (since the absolute max upload size is 10 MB, if they uploaded above
> that, I would still have the same behavior).  I have taken a look at the options
> for the config files, but I haven't found anything yet.  Any ideas?
> 
> Thanks,
> Fred
> 
> 
I'm really not sure about this one, but maybe this can be achieved via error
locations :

error_page   413  /toolarge;
location = /toolarge {
  proxy_pass ...
}
(or even with @locations)

and handle /toolarge within your application.





More information about the nginx mailing list