Rails file upload size limit

Mato picture Mato · Feb 4, 2010 · Viewed 19.4k times · Source

Does anyone know a good solution to limit the file upload size when running a Rails application with Passenger/mod_rails. The request should immediately be declined, so that the file doesn't get transferred to the server.

The solutions I've found so far all describe how to patch Mongrel to implement a limitation, but I have to use passenger with this application.

Answer

Jack Chu picture Jack Chu · Feb 4, 2010

Or if you're using nginx with passenger, add in the server block:

server {
  client_max_body_size 100M;
}

http://wiki.nginx.org/NginxHttpCoreModule#client_max_body_size