views:

50

answers:

3

I'm running a Rails app on an ubuntu hardy box with passenger. I also have a couple basic html sites running on the same box. My problem is that the apache vhost set up for the html sites seems to be blocking my Rails app from resolving at the proper url.

I have a number of Rails apps running on different slices using passenger, so I know how to make this work generally.

I'm not getting any errors in the terminal or in the apache logs. Everything appears to be working perfectly, but the site will simply not resolve at the proper url. Instead, when I go to the url where my Rails app should be, I see the site that is the apache default vhost on my slice.

To confirm my assumption, I disabled all of the vhosts on my slice associated with the static html pages. After doing that, my Rails app appeared at the proper url and worked fine. When I re-enabled the vhosts for the html sites, I was back to the same problem again.

My bet is that there's an easy configuration fix to this, but I can't figure it out. Anybody know?

Thanks.

Update to answer question in the comment

Yes, the static sites work fine by themselves. Under all circumstances, the static sites are fine.

My vhost files are using super basic setup. Static site vhost files look like this:

<VirtualHost *:80>

  ServerName foo.com
  ServerAlias www.foo.com

  DirectoryIndex index.html
  DocumentRoot /home/blah/public_html/foo/public

</VirtualHost>

Passenger vhost file looks like this:

<VirtualHost *:80>

  ServerName  bar.com
  ServerAlias www.bar.com

  DocumentRoot /home/blah/public_html/bar/current/public

</VirtualHost>
A: 

Did you have -MultiViews option turn on/off?

<VirtualHost *:80>
    ServerName www.phusion.nl
    DocumentRoot /websites/phusion
    <Directory /websites/phusion>
        Allow from all
    </Directory>

    RailsBaseURI /rails                   # <-- These lines have
    <Directory /websites/phusion/rails>   # <-- been added.
        Options -MultiViews               
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>                          
</VirtualHost>

The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements

Jirapong
I tried adding the multiviews option to the vhost that is serving the Rails app. That didn't seem to work. I got the same result.
MikeH
You might want to checkout this article - http://uhhuhyeah.com/distractions/HowtosetupyourserverforRailsandPassengerPartIII . They are other option to set in <Directory> .
Jirapong
Thanks, but it looks like he's just following the standard Slicehost tutorial and doesn't seem to really understand these settings himself. Not sure there's an answer there, but I do appreciate you trying to help.
MikeH
For good measure, I tried including all of your settings in my vhost file for the Rails site, but got the same result unfortunately.
MikeH
Which Linux Distro you are using? and Apache? I might be able to help because I'm also using similar setting here.
Jirapong
Ubuntu 8.04.2 (hardy). Apache 2.x. It's a standard slicehost setup.
MikeH
+1  A: 

If you want to verify your apache virtual host configuration try doing:

apache2 -S

or

apache2 -t -D DUMP_VHOSTS

both should dump your vhosts list. Maybe your rails virtual host gets assigned to some other IP?

knx
A: 

Your description of the problem suggests that your Rails site vhost configuration isn't claiming its host name, either due to a configuration issue or because another vhost claimed it first. Therefore requests to that domain get handled by the default vhost, which in Apache is usually the first one configured. Without seeing the complete configuration, it's hard to figure out where the issue is - I understand obfuscation, but in this case the stuff you're obfuscating is almost certainly where the problem lies.

pjmorse