Working on another project, which is in Ruby on Rails. RoR typically uses Mongrel to serve up the pages, and while there are tons of pages on how to get RoR and Fastcgi working together I have never been able to do this.
The solution I have used is having Apache as a frontend, proxying to a Mongrel server running on the same machine. This is not the fastest way, and with Mongrel being fairly single threaded, you would have to run Mongrel cluster to get decent performance. This is intended for the first pass of hosting, just to get things rolling.
Follow up:
Here is what our virtualhost looks like:
ServerName acvwparts.com
DocumentRoot /Sites/acvwparts
ServerSignature On
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /acvwparts/ http://localhost:3000/
ProxyPassReverse /acvwparts/ http://localhost:3000/
ProxyPass /bltn/ http://localhost:3001/
ProxyPassReverse /bltn/ http://localhost:3001/
ProxyPreserveHost On
The first 4 lines I have explained in my last post, the interesting stuff is what is next.
First we set up our permissions with Order deny,allow and Allow from all. The first one means to evaluate deny directives first, then allow directives. The second entry says to allow requests from any domain. This means anyone can access the proxy passthroughs.
To get Apache to forward links to the Mongrel instance, you use a pair of directives, ProxyPass and ProxyPassReverse. ProxyPass maps the remote server into the servers address range. The first parameter is where you want it visible, the 2nd parameter is where you want it to go to. ProxyPassReverse allows apache to alter the Location directive in redirects, so that the client is redirected properly when you use a redirection in RoR (used quite often).
For each mongrel Server you have running, you will always have this pair of directives. As you can see in our configuration, there are two Mongrel instances running mounted at two locations.
ProxyPreserveHost passes the Host: line from the request to the proxied machine. This is needed for rails to generate URL's properly
If you have done all of these things and are still having problems you are not alone. The problem you run into here is that all of your generated links don't have the path correctly. Naturally you would think to use --prefix when starting Mongrel, but it turns out doing this causes you to have the path repeated twice.
The trick to fix rails is to add the following in your environment.rb:
ActionController::AbstractRequest.relative_url_root = "/acvwparts"
Your mounted path should be filled in on the right. This causes all URL's generated by Rails to have whatever you pass in appended to it. Using this, you do *not* specify a prefix when starting Mongrel.
config.action_controller.relative_url_root = "your_root"
Originally found on http://giantrobots.thoughtbot.com/2009/4/15/rails-2-3-2-upgrade-gotchas