Rails 1.2.x and proxy balancer configuration

A couple of days ago I was in a hurry to move a rails application to my new server running Virtualmin. I started out with the Rails 2.0.2 install script, and then ported my code into that. Due to extensive use of a plugin that seems to no longer work with Rails 2.0, I had to revert to version 1.2.6 for that particular application (as I said, I was in a hurry).

Unfortunately this didn’t work “out of the box”. I got a routing error because mongrel got an extra slash in front of every request. It got “//” instead of “/” “//controller/action” instead of “/controller/action” etc.

The quick fix was to manually edit the apache directives for that particular host to read "BalancerMember http://localhost:3000" instead of "BalancerMember http://localhost:3000/" that was put there by the install script. (notice the removal of the trailing slash). And it worked perfectly.

I haven’t had time to check if rails 2.0 also work without that final slash, but at least it seems to me like there is a difference in how rails 1.2.x and 2.0 interprets it’s requests when it comes from the apache proxy.

Just thought I’d let you know. Perhaps someone else will end up in a similar situation.

And BTW, perhaps it would be nice idea to put the “RequestHeader set X_FORWARDED_PROTO ‘https’”-trick into the apache configuration for a rails-installation on an SSL-host by default? I think quite a lot of rails applications with https-services use this trick to know if a request came through a secure connection to the proxy. At least I know I’m using it :slight_smile:


Svein Magne