views:

4951

answers:

5

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?

+6  A: 

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.

Michael Haren
I would strongly recommend Passenger. Makes hosting rails almost as easy as PHP.
Samuel
I'm on windows so I don't think that will work for me. Thanks, though.
Michael Haren
It's actually ActionController::Base.relative_url_root since Rails 2.3.x
Wojciech Kaczmarek
A: 

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

Ryan Bigg
-1, read the comments on his answer.
Samuel
+1, you didn't provide a link for him Samuel :)
dylanfm
Even so, it's the first Google result and Michael added the windows2003 tag over 3 hours ago.
Samuel
And what does windows2003 have to do with it? Passenger works.
Ryan Bigg
According to the passenger site windows is not supported. If it is, please provide a link saying so and I'll check it out!
Michael Haren
+1  A: 

having a simmilar issue

would like to access redmine at server.tld/

and svn server.tld/svn/

when i access / all is fine /svn tries to be handled by redmine and gives me a 404

when i comment the proxy pass lines /svn works fine ....

Any idea?

Thanks

<Location /svn>
        DAV svn
    SVNParentPath /home/subversion
</Location>
<Location />
       SetHandler balancer-manager
       Order allow,deny
       Allow from all
       ProxyPass  balancer://redmine/
       ProxyPassReverse  balancer://redmine/
</Location>
<Proxy balancer://redmine>
        BalancerMember http://127.0.0.1:8001 keepalive=on max=2 retry=30
        BalancerMember http://127.0.0.1:8002 keepalive=on max=2 retry=30
        BalancerMember http://127.0.0.1:8003 keepalive=on max=2 retry=30
</Proxy>
@Tim: you should ask this in your own question. My guess, though: do you have redmine and svn under the same root directory? If so, try breaking them into separate trees.
Michael Haren
+1  A: 

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

Damien
A: 

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.

Aram Verstegen
But does it work on Windows?
Michael Haren
No - with no planned support for Windows either it appears. See http://bitnami.org/forums/forums/2/topics/477
Damien