redirect_to :future #思维驱动 » Blog Archive » 让多个rails应用跑在同一个服务器上。


如果你用apache或是lighttpd加上fastcgi跑ruby on rails并且建立几个虚拟机的话默认情况下错误日志中应该出现:[Mon Mar 20 19:49:50 2006] [error] [client] FastCGI: incomplete headers (35 bytes) received from server “/var/www/xxx/xxx/public/dispatch.fcgi”


I run two Ruby Rails 1.0 apps successfully using fastcgi.

Only problem encountered so far: conflict between sesson cookies of the two apps when they try to store and restore their own sessions-trying to use the session cookie of the other application. Both are using the default setup.

Error message in Apache error.log:
FastCGI: incomplete headers (35 bytes) received from server “/blah/ruby_app/public/dispatch.fcgi”

Diagnosis and Fix

To check:
Assumption: you have two apps, ruby_app_1 and ruby_app_2 on the same server.

On a client machine:

  1. quit your browser (all windows).
  2. restart browser and try ruby_app_1
    If it now works then you may have the conflict in session id’s
    (restarting the browser clears the browser-session cookie cache)
  3. now try ruby_app_2
  4. now try ruby_app_1 again and be sure to reload from the server, not the browser’s page cache. On IE, use shift-reload.
    If it no longer works then you probably have the conflict

The problem is that both apps are trying to store/restore the ruby session and both are using the default ruby cookie of _session_id

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = ‘_ruby_app_1′

to end of environment.rb