# Using mongrel to serve 2 rails apps

**URL:** <https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009>\
**Category:** Rails\
**Created:** [January 23, 2007, 12:36am UTC](https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009 "2007-01-23T00:36:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 23, 2007, 12:36am UTC](https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009/1 "2007-01-23T00:36:13Z")

</div>

hi,

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

e.g.

[www.myapp.com](http://www.myapp.com)  
[www.myapp.com/forums](http://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](http://www.myapp.com)  
my forums app on port 81 at [www.myapp.com](http://www.myapp.com)

rather than giving out the URL www.myapp,com:81 for my forums, I would  
like to use [应用宝官网-全网最新最热手机应用游戏下载](http://www.myapp.com/forums) and have this redirect invisibly to  
[www.my.com:81](http://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

---

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 23, 2007, 1:05am UTC](https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009/2 "2007-01-23T01:05:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 23, 2007, 1:11am UTC](https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009/3 "2007-01-23T01:11:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 23, 2007, 11:59am UTC](https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009/4 "2007-01-23T11:59:53Z")

</div>

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](http://mongrel.rubyforge.org/rdoc/classes/Mongrel/Configurator.html#M000101)

John H. schrieb:

---

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 26, 2007, 9:09pm UTC](https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009/5 "2007-01-26T21:09:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 23, 2007, 5:08am UTC](https://www.ruby-forum.com/t/using-mongrel-to-serve-2-rails-apps/83009/6 "2007-01-23T05:08:47Z")

</div>

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](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
