Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

In case you still wish to use Mongrel + Apache using a reverse proxy here is how I solved the same issue on our system (Win2k3, Apache 2.2, trunk of Redmine). The secret is to install your mongrel service using --prefix /redmine which tells it to serve it from http://localhost:port/redmine

In Apache httpd.conf (or suitable include file):

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<IfModule mod_proxy.c>
ProxyRequests Off
#No need to forward on static content - let apache do it faster
ProxyPass /redmine/images ! 
ProxyPass /redmine/stylesheets ! 
ProxyPass /redmine/javascript ! 
# Remove the following entry on public sites as this is insecure
ProxyPass /redmine/plugin_assets !
ProxyPass /redmine/help ! 
ProxyPass /redmine http://localhost:4000/redmine
ProxyPassReverse /redmine http://localhost:4000/redmine
ProxyPreserveHost On
#continue with other static files that should be served by apache
Alias /redmine/images C:/Repositories/redmine/public/images/
Alias /redmine/stylesheets C:/Repositories/redmine/public/stylesheets/
Alias /redmine/javascript C:/Repositories/redmine/public/javascript/
# Remove the following on public sites as this is insecure
Alias /redmine/plugin_assets C:/Repositories/redmine/public/plugin_assets/
Alias /redmine/help C:/Repositories/redmine/public/help/
</IfModule>

# Make sure apache can see public and all subfolders - not suitable for public sites
<Directory "C:/Repositories/redmine/public/">
    Allow from all
    Order allow,deny
</Directory>

Mongrel is installed as such:

mongrel_rails service::install --prefix /redmine -N redmine_prod -p 4000 -e production -c C:\Repositories\redmine

Hope that helps someone. Initially, I tried setting up Apache + fastcgi etc but I lost more precious hair - it's not Windows friendly.

P.s. I found this PDF a very useful referene: http://www.napcsweb.com/howto/rails/deployment/RailsWithApacheAndMongrel.pdf

/Damien

Passenger (http://modrails.com) is a better alternative to fastcgi because it's very easy to configure I would recommend using this for hosting your rails apps using a similar configuration to what you have now

I agree with Radar. Passenger is really easy to set up, lets Rails apps share memory, removes the burden of managing a cluster of mongrels and requires virtually no configuration. All you need are a special 'config.ru' file with a RackUp config and a DocumentRoot pointing to RAILS_ROOT/public set in Apache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top