Configuring Ruby On Rails App in a subdirectory under Apache

Michael Haren picture Michael Haren · Jan 22, 2009 · Viewed 16.8k times · Source

I've got apache2.2 on windows. I'm trying to serve both subversion (/svn) and redmine (/redmine). I have svn running fine with this config:

<Location /svn>
  DAV svn
  SVNParentPath C:/svn_repository
  ...
</Location>

This is working great--my svn users can hit http://mybox/svn just fine.

Now I want to add another directory for a rails app (RedMine):

I followed the advice in this question to setup a mongrel server and have apache proxy clients through to it. It works fine if I make it the root--but I'm having trouble making it in a subdirectory:

<Location /redmine>
  ProxyPass http://localhost:3000/
  ProxyPassReverse http://localhost:3000/
</Location>

Any suggestions?

Answer

Michael Haren picture Michael Haren · Jan 22, 2009

Here's what I had to change:

I removed the trailing slash:

<Location /redmine>
  ProxyPass http://localhost:3000
  ProxyPassReverse http://localhost:3000/
</Location>

And in my rails app:

# added to end of file C:\redmine\config\environment.rb
ActionController::AbstractRequest.relative_url_root = "/redmine"

Now it's working!


I wasn't completely happy with this approach--I ran into some redirect issues. This is another attempt which seems to be working well so far.

This second approach seems better.


UPDATE:

As noted in the comments, for more recent apps running on Rails 2.3.2+, use this instead:

config.action_controller.relative_url_root = '/redmine'

I put it in the new additional_environment.rb file.