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?

Hi,

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

On Jan 31, 4:04 am, Me [email protected] wrote:

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?


Thomas R. “TomK32” Koll <> http://ananasblau.com
just a geek trying to change the world
TomK32 (Thomas R. Koll) · GitHub

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.

On Sat, Jan 31, 2009 at 6:58 AM, Chris H. [email protected]
wrote:

I can only speak for unix systems but the path is usually the same:

just a geek trying to change the world
TomK32 (Thomas R. Koll) · GitHub

Hi, are you using a different ServerName for each virtual host? Also,
did
you
correctly configure the equivalent of Unix hosts’ file under Windows?

-Conrad

On Sat, Jan 31, 2009 at 7:20 AM, Me [email protected] wrote:

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.


Hassan S. ------------------------ [email protected]

On Sat, Jan 31, 2009 at 7:20 AM, Me [email protected] wrote:

Usually there are more than one mongel and they run on port 3000
is
you
correctly configure the equivalent of Unix hosts’ file under Windows?

-Conrad

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.

-Conrad

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

On Sat, Jan 31, 2009 at 7:33 AM, Chris H. [email protected]
wrote:

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.


Hassan S. ------------------------ [email protected]

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

On Sat, Jan 31, 2009 at 9:30 AM, Hassan S. <

On Sat, Jan 31, 2009 at 7:50 AM, Me [email protected] wrote:

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?


Hassan S. ------------------------ [email protected]

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.

On Jan 31, 9:49 am, Hassan S. [email protected]

The first virtual host.

My sever locally is ex. 192.168.1.1

I go to 192.168.1.1/myapp1

that app in my vitual host works

If I go to 192.168.1.1/myapp2

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

On Jan 31, 9:54 am, Hassan S. [email protected]

On Sat, Jan 31, 2009 at 8:01 AM, Me [email protected] wrote:

The first virtual host.

My sever locally is ex. 192.168.1.1

I go to 192.168.1.1/myapp1

that app in my vitual host works

If I go to 192.168.1.1/myapp2

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.


Hassan S. ------------------------ [email protected]

On Sat, Jan 31, 2009 at 8:11 AM, Me [email protected] wrote:

ServerName employeedb

ServerName turindata

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. http://192.168.1.1/myapp1, if
that’s what you want.


Hassan S. ------------------------ [email protected]

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

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

ProxyRequests Off
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/

On Jan 31, 10:08 am, Hassan S. [email protected]

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:
http://192.168.1.1/turindata

no problem

the other app bombs

On Jan 31, 10:19 am, Hassan S. [email protected]

On Sat, Jan 31, 2009 at 8:22 AM, Me [email protected] wrote:

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

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.


Hassan S. ------------------------ [email protected]

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 http://192.168.1.1/turindata
I should be able to go to http://192.168.1.1/employeedb

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.

On Jan 31, 10:38 am, Hassan S. [email protected]

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.

On Sat, Jan 31, 2009 at 10:56 AM, Hassan S. <

On Sat, Jan 31, 2009 at 9:01 AM, Chris H. [email protected]
wrote:

IP/app
IP/app1

OK, dump all the virtual host stuff you’re not using and under the
default host put something like:

ProxyPass /app/ http://localhost:3000/
ProxyPassReverse /app/ http://localhost:3000/

ProxyPass /app1/ http://localhost:3001/
ProxyPassReverse /app1/ http://localhost:3001/

Done.

Hassan S. ------------------------ [email protected]