Using mongrel to serve 2 rails apps

hi,

i’m using mongrel as my production webserver, and i want to serve 2
rails apps

e.g.

www.myapp.com
www.myapp.com/forums

i want in effect to connect the second app to /forums on the same url.

currently i have 2 mongrels running as follows:-

my main app on port 80 at www.myapp.com
my forums app on port 81 at www.myapp.com

rather than giving out the URL www.myapp,com:81 for my forums, I would
like to use www.myapp.com/forums and have this redirect invisibly to
www.my.com:81

i’ve looked on the mongrel website and I’ve come across mongrel clusters
and also mogrel configuration scripts - but this all quite complex and
i’m not sure if either is the answer.

any pointers?

cheers,

-john

John H. wrote:

I’d suggest putting a web server with load balancing and proxying
support in front of your mongrels such as Apache or Lighty. Then use
the prefix feature of mongrel to bind app2 to /forums/.

–R

Randall Potter wrote:

John H. wrote:

I’d suggest putting a web server with load balancing and proxying
support in front of your mongrels such as Apache or Lighty. Then use
the prefix feature of mongrel to bind app2 to /forums/.

–R

thanks Randall - i have lighty installed but i’m not sure how to ‘put in
in front’ of the two mongrels…

presumably i start the 2 mongrels on some higher port numbers, say 8100
and 8101.
then run lighty on port 80.

then do i not then need to tell lighty to bind /forums/ to the 2nd
mongrel?
(or something like that…)

cheers,

-john

Hello,
You could also try the following:
Use ‘mongrel_rails start’ with ‘–script=/path/to/script.rb’ and use
any options you like in this file, especially the uri[1] method.
You can then mount handlers to different mount points.
It should work, but I never tested it, so I’ve no idea concerning
performance issues.

Best regards

[1]
http://mongrel.rubyforge.org/rdoc/classes/Mongrel/Configurator.html#M000101

John H. schrieb:

thanks Randall,

i’m getting close now… but still not quite there yet…

i have 2 mongrels on 8100 and 8101.

i’m trying to configure lighty to point / to 8100 and /forums to 8101.
so, just starting with the main site on 8100, i have this in my
lighttpd.conf file…

proxy.balance = “hash”
proxy.server = ( “/” => (( “host” => “127.0.0.1”, “port” => 8100))

but all i get is a blank page - which is better than an error message i
guess…

does anyone have a working lighttpd.conf file i could learn from?

cheers,

-john

John H. wrote:

(or something like that…)

cheers,

-john

You do need to tell Lighty where to find the mongrels it’s forwarding
to. Look into the documentation for Lighty’s mod_proxy for the syntax.

Using your example; you want to forward / to your primary app at
http://localhost:8100 and forward /forums/ to http:localhost:8101.

When you start the mongrel(s) for the forum application you need to be
sure to pass the --prefix=/ option (e.g. mongrel_rails start
–prefix=/forums -e production -d ) otherwise, your link_to, button_to
et. al. will get confused and keep trying to send you back to app1.

–R

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs