Hunter''s Lists
2006-Jan-12 22:51 UTC
[Rails] File Upload Problems With Apache and Lighttpd But Not Webrick...
I am having trouble uploading files through a form when using Apache (production) or Lighttpd (development). The odd thing is that when I force script/server to load Webrick, the upload works just fine on the same code-base. When it fails, the upload just sits there forever. Some browsers eventually return an error code, others spin for a long time... Anyway, it never recovers. The file is a 1.7MB SWF (Flash) file and we''re using File Column. Since it happens on Apache and Lighttpd, I''m thinking either: 1. FCGI. Both of those server setups are using FCGI but Webrick is not... Is FCGI doing something bad? 2. MIME issues of some kind?? I dunno about this one but I''ve tried everything so I''m looking at strange stuff. Both have entries for SWF files in their MIME types though, so this shouldn''t be a problem, right? Anyway, I''m on MacOS X 10.4. Has anyone seen anything like this? Any help appreciated. Cheers.
Nick C.
2006-Jan-13 08:57 UTC
[Rails] Re: File Upload Problems With Apache and Lighttpd But Not We
Hunter''s Lists wrote:> I am having trouble uploading files through a form when using Apache > (production) or Lighttpd (development). The odd thing is that when I > force script/server to load Webrick, the upload works just fine on the same > code-base.>...> Anyway, I''m on MacOS X 10.4. > > Has anyone seen anything like this? Any help appreciated.Are you uploading via Safari? Lighttpd requires the following to be added to your lighttpd.conf file for uploads via file_column to work: $HTTP["useragent"] =~ "^(.*MSIE.*)|(.*AppleWebKit.*)$" { server.max-keep-alive-requests = 0 } This doesn''t explain the Apache troubles you''re experiencing though. Perhaps if you posted the error message you''re receiving it might help track it down. Also check the development.log file to see what''s going on when the browser hangs. -- Posted via http://www.ruby-forum.com/.
Hunter''s Lists
2006-Jan-13 17:01 UTC
[Rails] Re: File Upload Problems With Apache and Lighttpd But Not We
Nick, Thanks for getting back. Yes, I am on Safari and your trick did solve the problem on Lighttpd - thanks! Unfortunately, production is Apache so I still need to solve that issue. When this happens on Apache, it just hangs there. The last thing in the log file is the rendering of the page that submits the file - nothing about the upload submission. The browser error message depends on the browser. Safari says it lost a connection, IE just gives ''Page Cannot Be Displayed'' though both browsers hang for a few minutes before they return the error. If anyone could give me any tips as to what I could do to continue testing this, I''d really appreciate it. Is there a keep alive setting for Apache similar to this Lighttpd setting that I should tweak? Cheers, Hunter> From: "Nick C." <graphis1@mac.com> > Reply-To: <rails@lists.rubyonrails.org> > Date: Fri, 13 Jan 2006 09:57:13 +0100 > To: <rails@lists.rubyonrails.org> > Subject: [Rails] Re: File Upload Problems With Apache and Lighttpd But Not We > >> I am having trouble uploading files through a form when using Apache >> (production) or Lighttpd (development). The odd thing is that when I >> force script/server to load Webrick, the upload works just fine on the same >> code-base. > >> ... > >> Anyway, I''m on MacOS X 10.4. >> >> Has anyone seen anything like this? Any help appreciated. > > > Are you uploading via Safari? Lighttpd requires the following to be > added to your lighttpd.conf file for uploads via file_column to work: > > $HTTP["useragent"] =~ "^(.*MSIE.*)|(.*AppleWebKit.*)$" { > server.max-keep-alive-requests = 0 > } > > This doesn''t explain the Apache troubles you''re experiencing though. > Perhaps if you posted the error message you''re receiving it might help > track it down. Also check the development.log file to see what''s going > on when the browser hangs.
Nick C.
2006-Jan-14 00:13 UTC
[Rails] Re: Re: File Upload Problems With Apache and Lighttpd But No
Hunter''s Lists wrote:> Nick, > > Thanks for getting back. > > Yes, I am on Safari and your trick did solve the problem on Lighttpd - > thanks!Pleased to hear it :)> If anyone could give me any tips as to what I could do to continue > testing this, I''d really appreciate it. > > Is there a keep alive setting for Apache similar to this Lighttpd > setting that I should tweak?I did some digging, and found this very handy article by Scott Laird about optimising Apache for use with Rails: http://scottstuff.net/blog/articles/2005/07/20/apache-tuning-for-rails-and-fastcgi Here''s a quote - "By default, FastCGI assumes that your server will respond to queries within 30 seconds. I added the -idle-timeout 120 parameter just so I can deal with really slow responses better." Here''s my guess: In your locally hosted environment the 1.7mb upload flies up well within the 30 seconds and the limit that FastCGI imposes isn''t a problem. When you switch to a remote hosted (I''m assuming?) production environment, the upload takes over 30seconds causing FastCGI to choke. Try adding the following to your apache.conf file as Scott suggests, replacing /path/to/your with the correct path for your server environment: FastCgiServer /path/to/your/dispatch.fcgi -idle-timeout 120 \ -initial-env RAILS_ENV=production -processes 2 This forces the timeout to a more sensible number and runs two FastCGI processes. (Try going a bit higher with the timeout value if things still aren''t happy.) Good luck! -- Posted via http://www.ruby-forum.com/.