Multiple apps on one lighty server

Does anybody know how to run multiple rails apps off of one server?
All I can imagine is running mongrel with different port numbers, but
since (internal server) lighttpd is set up to run on port 81, and
mongrel is a layer below lighty, that would mean that the machine would
be serving at 192.168.0.119::81:3000 for example. And I don’t think that
multiple ports are allowed, so that doesn’t work. Anybody know how to do
it? Birds-eye view is fine. Once I understand that, I can probably look
up the specifics on the net.

Thanks!

Hi Sean

since (internal server) lighttpd is set up to run on port 81, and
mongrel is a layer below lighty, that would mean that the machine would
be serving at 192.168.0.119::81:3000 for example. And I don’t think that
multiple ports are allowed, so that doesn’t work. Anybody know how to do

Ports in Unix are not in any way hierarchical. So, you would have
lighty listening on port 81;

192.168.0.119:81

…and mongrel(s) listening on port(s) 3000 (and up), i.e;

192.168.0.119:3000

…and maybe

192.168.0.119:3001
192.168.0.119:3002

…depending on your setup

So, the idea is that a request comes in on port 81, and lighty
redirects it to a different port (3000, or whatever).

Cheers

David

Thanks David. But I’m still confused. Would the browser looking for one
of the apps be pointing to 192.168.0.119:81 or 192.168.0.119:3000? I’d
guess it’d have to be 192.168.0.119:3000, because otherwise lighty has
no way to know who to redirect to, but if it it is 3000, then how does
the server know to give the request to lighty in the first place?

Sean C. wrote:

Thanks David. But I’m still confused. Would the browser looking for one
of the apps be pointing to 192.168.0.119:81 or 192.168.0.119:3000? I’d
guess it’d have to be 192.168.0.119:3000, because otherwise lighty has
no way to know who to redirect to, but if it it is 3000, then how does
the server know to give the request to lighty in the first place?

The browser makes its request to 192.168.0.119:81 and will include the
information that it is trying to access, for example, myapp.foo.bar.
Thus the request arrives at lighty. I’m not familiar with how you
configure lighty, but somewhere in its configuration it will need the
information that requests for “myapp.foo.bar” need to be forwarded on to
192.168.0.119:3000. The browser does not know (or need to know) the
port number of the mongrel process(es) behind lighty. Indeed, you
wouldn’t want it to know because you might want to change the number or
location of the mongrel processes.

HTH
John

Hi,

John W. wrote:

The browser makes its request to 192.168.0.119:81 and will include the
information that it is trying to access, for example, myapp.foo.bar.
Thus the request arrives at lighty. I’m not familiar with how you
configure lighty, but somewhere in its configuration it will need the
information that requests for “myapp.foo.bar” need to be forwarded on to
192.168.0.119:3000.

That’s quite easy. The relevant part of the lighttpd.conf would look
something like this.

server.modules = (

“mod_proxy”,

)

The first application is served by a mongrel on port 3000.

$HTTP[“host”] =~ “foo.example.com” {

proxy.server = ( “/” =>
((“host” => “127.0.0.1”, “port” => 3000)))
}

The second application is served by two mongrels on port 3000.

$HTTP[“host”] =~ “bar.example.com” {

proxy.server = ( “/” =>
((“host” => “127.0.0.1”, “port” => 3000),
(“host” => “127.0.0.1”, “port” => 3001)))
}

Take a look at http://trac.lighttpd.net/trac/wiki/Docs%3AModProxy for
details concerning the configuration of mod_proxy under lighttpd.

Lutz

Sorry for the bump - I’m just getting to the point where I can sort of
understand this. One question: What do “host” and “bar.example.com
signify in the $HTTP line? Does this mean, for example, that I can set
“host” to an arbitrary network address, like 192.168.0.333? Or
bar.example.com” to an arbitrary domain name?

For example, if I have two applications, and I want to separate them so
that one will run at 192.168.0.300, and the other will run at
192.168.0.301, is this where I set this?

Thanks, and sorry of this confuses. I’m a little confused myself.
sean

Lutz H. wrote:

The second application is served by two mongrels on port 3000.

$HTTP[“host”] =~ “bar.example.com” {

proxy.server = ( “/” =>
((“host” => “127.0.0.1”, “port” => 3001),
(“host” => “127.0.0.1”, “port” => 3002)))
}

Silly me:

Lutz H. wrote:

The second application is served by two mongrels on port 3000.

$HTTP[“host”] =~ “bar.example.com” {

proxy.server = ( “/” =>
((“host” => “127.0.0.1”, “port” => 3000),
(“host” => “127.0.0.1”, “port” => 3001)))
}

This must be like this, of course

proxy.server = ( “/” =>
((“host” => “127.0.0.1”, “port” => 3001),
(“host” => “127.0.0.1”, “port” => 3002)))

Lutz