Apache Virtual Host as SubPath of Default Host

Is it possible to have an Apache’s virtual host run as a subpath of the default host?

For example I have the default name based host as:



<VirtualHost *:80>
    DocumentRoot "/srv/www/htdocs"
    ServerAdmin me@whatever.com
    ServerName  linuxserver.domain.com
    ErrorLog    /var/log/apache2/error_log

    <Directory "/srv/www/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>


I’d like to add a vhost as:



<VirtualHost *:80>
    ServerAdmin me@whatever.com
    **ServerName linuxserver.domain.com/railsapp**
    DocumentRoot /srv/www/railsapp/public/

    ETC....


I want the subpath of the server to direct to an entirely new DocumentRoot (this is to run a Ruby on Rails app outside of the default VHost.

When I try it as written above I get:
The requested URL /sepsisdoc was not found on this server.

I’ve done this with sub domains and alternate dsn that refer to the same IP but never like this.

Thanks,

LarsenMTL

I would think not, because linuxserver.domain.com/railsapp would not be a valid ServerName.

Yeah, I don’t get it. Why would you want to use a named virtual host if you’re using the same server name for both apps?

What would you like to be in the browser’s address bar when the user visits http://linuxserver.domain.com/railsapp? To go back to http://linuxserver.domain.com but actually run the railsapp?

I’d like it to stay http://linuxserver.domain.com/railsapp. The regular domain serves mostly HTML with some plain old CGIs. I wanted to section the rails app into its own virtual host because of the extra apache configuration associated with running rails under fast cgi. I figured there was less risk in breaking the rest of the server.

After working on it for a while, I have to agree with control-z that Apache’s not gonna do it. I worked around the problem by running the rails app on port 81 and mod_rewriting http://linuxserver.domain.com/railsapp to http://linuxserver.domain.com:81. That way I can still give the users a “nicer” url.

Really the best solution would be to sub-domain it into railapp.linuxserver.domain.com, but Network services isn’t going to like that.

If anyone has better ideas, I’d love to hear 'em.

Thanks.

Are you sure you can’t just use a ScriptAlias and then a <Directory> directive to do what you need?

It’s true tho that vhost configs are very neat and are more insulated from the overall server config. Your network guys would prefer you to use port 81 instead of setting up a new hostname for a vhost? You don’t even need another IP address (unless you need https for the rails app). Keep in mind also that a standalone ruby app doesn’t get all the benefits of running apache in the first place (static html/image performance, logs in one place, etc.).

arseNal, thanks. I ended up taking your advice and using an Alias with a corresponding <Directory>. It took me a bit to figure out why my rails app couldn’t find files after I did this (I had used absolute paths on everyting (shudder)). Everything is straight now.

Thanks, again.