Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to have a setup where I want to run a squirrelmail and Passenger on the same apache server, having a url point to squirrelmail and everything else handled by passenger. I've gotten so far that both squirrelmail and passenger will run fine by themselves but when passenger is running it handles all urls.

So far I've tried using Alias and Redirect to point a webmail/ url to squirrelmails directory but that does not work.

Here is my httpd.conf file:

<VirtualHost *:80>
  ServerName not.my.real.server.name
  DocumentRoot /var/www/sinatra/public
  # Does not work:
  #Redirect webmail/ /usr/share/squirrelmail/
  #<Directory /usr/share/squirrelmail>
  #  Require all granted
  #</Directory>
  <Directory /var/www/sinatra/public>
    Order  allow,deny
    Allow  from all
  </Directory>
</VirtualHost>

apache2.conf has these files added for passenger, other than this I have not made any changes from the standard Ubuntu Server 12.04 installation of apache:

# passenger config
  LoadModule passenger_module /home/kenneth/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
  PassengerRoot /home/kenneth/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.15
  PassengerRuby /home/kenneth/.rvm/wrappers/ruby-1.9.3-p194/ruby

The passanger config.ru file:

require './index'
run Sinatra::Application
share|improve this question
    
Could you please provide your Apache config for passenger? –  quanta Aug 30 '12 at 7:06
    
@quanta Done. I have only added the lines to apache2.conf as was instructed by the passenger install script. For good measure I have included the config.ru file as well. It is a fresh install so not much has been changed. –  Kenneth Aug 30 '12 at 7:19
    
Do you have only one domain and you want domain.com/webmail go to squirrelmail and domain.com/sinatra go to your Rails app? –  quanta Aug 30 '12 at 7:42
    
@quanta Yes, only one domain. Ideally I would like domain.com/webmail to go to squirrelmail and the rest of domain.com to go to the app. However if domain.com/sinatra will get both working I can be happy with that. –  Kenneth Aug 30 '12 at 7:45
add comment

1 Answer

up vote 1 down vote accepted

Try this:

<VirtualHost *:80>
    ServerName not.my.real.server.name
    DocumentRoot /var/www

    Alias /webmail "/usr/share/squirrelmail"
    <Directory /usr/share/squirrelmail>
        Order allow,deny
        Allow from all
    </Directory>

    <Directory /var/www/sinatra>
        RackBaseURI /sinatra
        PassengerResolveSymlinksInDocumentRoot On
        PassengerAppRoot /var/www/sinatra
    </Directory>
</VirtualHost>

UPDATE

I think that we can tell Rails to ignore particular URL by turning off the PassengerEnabled:

<VirtualHost *:80>
    ServerName not.my.real.server.name
    DocumentRoot /var/www/sinatra/public

    <Directory /var/www/sinatra/public>
        Order allow,deny
        Allow from all         
    </Directory>

    Alias /webmail "/usr/share/squirrelmail"
    <Location /webmail>
        PassengerEnabled off
    </Location>
</VirtualHost>

Give it a try!

share|improve this answer
    
Since it is a sinatra app RailsBaseURI was changed to RackBaseURI and I just needed to point the paths to where the config.ru file was stored and it works. Thank you. I have edited your answer with the tweaks that made it work. –  Kenneth Aug 30 '12 at 9:27
    
@Kenneth: thank you. I'm not familiar with sinatra app. Updated my answer. –  quanta Aug 30 '12 at 9:59
    
That is it, spot on. Sinatra now handles all URIs except webmail/. Thanks for going the extra distance. If I could upvote twice, I would :) –  Kenneth Aug 30 '12 at 11:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.