rails with apache virtual hosts, mongrel

Under windows, I am able to set up one virtual host that works with mongrel no problem. The issue is when I set up additional ones I cannot get to them. I look in the log file of the first app and it is trying to go there. Does anyone know how to set up multiple virtual hosts with rails?


This is not a rails problem but an issue for your webserver. I can only speak for unix systems but the path is usually the same:

user sends a request to port 80, the webserver (e.g. apache) accepts it and decides wether to deliver a file or proxy the request to the mongrel. Usually there are more than one mongel and they run on port 3000 upwards.

Let us know about you system details, what webserver you use.

ciao, tom

windows, apache 2.2. I set the virtual hosts like the docs say but I can only get to one of them, the first one in the list of virtual hosts.

Hi, are you using a different ServerName for each virtual host? Also, did you

correctly configure the equivalent of Unix hosts’ file under Windows?


Do you need to modify the hosts file if I go to my server address? Yes i have a different ServerName for each one.

So are you accessing your server by IP address or host name? If it's the former you have to use a different IP for each virtual host.

Perhaps you should post the relevant parts of your conf files.

Hi, I’m not a Windows expert but I believe that you do have to modify the hosts’

file to contain all the server names contained in your virtual hosts’ file.


My server is local. IP address on my netowrk at home. I go to IP/?? for my rails apps

If you want to use Named Virtual Hosts, then those names need to be resolvable, though DNS, NIS, your local hosts file -- something.

OK, well like in the previous replies, the first one works no problem it is the ones after in the file that do not work.

The "first one" /what/? Hostname? Is that the actual hostname of your computer? A minute ago you said you were accessing your server by IP address. Which is it?

The first virtual host.

My sever locally is ex.

I go to

that app in my vitual host works

If I go to

it says page cannot be displayed. It is the rails error page coming from myapp1.

The above has exactly nothing to do with "virtual hosts", so I'm not sure where your subject line comes from. If you're trying to "fix" the above situation with virtual host directives, you're going to be badly disappointed :slight_smile:

You need appropriate proxy settings for your *one* host.

OK I was trying to avoid pasting the virtual hsots file but here it goes:

NameVirtualHost *:80

<VirtualHost *:80> ServerName employeedb DocumentRoot "F:/BACKUP/Backup/Web_apps_svn_working/employeedb/public"

RewriteEngine On

<Directory "F:/BACKUP/Backup/Web_apps_svn_working/employeedb/public"

Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>

ProxyRequests Off ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ ProxyPreserveHost on


<VirtualHost *:80> ServerName turindata DocumentRoot "F:/BACKUP/Backup/Subversion Server/httpd/deploy_apps/ Turindata/public"

<Directory "F:/BACKUP/Backup/Subversion Server/httpd/deploy_apps/ Turindata/public" > Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>

ProxyRequests Off ProxyPass / http://localhost:3001/ ProxyPassReverse / http://localhost:3001/ </VirtualHost>

Might work -- if you were accessing your server /using those names/ e.g. http://employeedb/ and http://turindata/

So either do that, or dump all the virtual host stuff and fix your proxy settings to respond to the format e.g., if that's what you want.

Ok, well this is where it gets odd, like I said before I can go to:

I have my local server set up for http requests from my router. I can go to:

no problem

the other app bombs

It's not "odd" at all. You're seeing the first app that matches as the default. That is NOT an indication that it's "working", even partially.

If you don't use the defined server names to access your app, the current configuration *WILL NOT WORK*.

I suggest you first make up your mind how you want to access your server, as two virtual hosts, or 1 host with separate apps as you're apparently attempting now.

huh, well I am doing it according to the apache docs.

the *:80 routes all traffic from port 80 and the ServerName differentiates between the different virtual hosts.

I go to I should be able to go to

If this is not correct can you please instruct me how to make this happen somehow?

I am not an apache guru just trying to go by the rails stuff I have found and apache docs.

One more time -- the above has nothing to do with "virtual hosts". Nothing. At. All. Let's try again.

Check one, and only one:

I want to access my apps as separate virtual hosts, as in:     http://employeedb/     http://turindata/

I want to access my apps on one host, in this case '',     using different paths:

Those are your choices. Either is easily implemented.

Just make up your mind.

IP/app IP/app1

Not sure how to do it using mongrel on apache. All I have seen it doing it with virtual hosts. proxy to mongrel and back.