Nginx – How to make uploading large (more than 1MB) files work with nginx, rails and uploadify

debiannginxrubyruby-on-railsupload

I have problem with my production nginx configuration (on my development machine with mongrel everything works). My environment is: nginx as proxy, rainbows as backend running rails 3.1 application with ruby 1.9.2.

When I'm trying to upload large file (more than 1MB) I see 502 error on my website and in nginx error log file:

2012/04/02 14:45:17 [error] 14415#0: *658 sendfile() failed (32: Broken pipe) while sending request to upstream, ....

What I've tried:

  • setting client_max_body_size 5m;
  • keepalive_timeout 600;

Uploading smaller files works fine. What could be the problem?

Best Answer

After some time I've found that you have to repeat max file upload size setting in rainbows configuration file:

client_max_body_size(2 * 1024 * 1024)