# Lighty + Mongrel?

**URL:** <https://www.ruby-forum.com/t/lighty-mongrel/54500>\
**Category:** Rails\
**Created:** [March 7, 2006, 4:22am UTC](https://www.ruby-forum.com/t/lighty-mongrel/54500 "2006-03-07T04:22:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [March 7, 2006, 4:22am UTC](https://www.ruby-forum.com/t/lighty-mongrel/54500/1 "2006-03-07T04:22:37Z")

</div>

On httpd I use ProxyPass and ProxyPassReverse to forward requests to  
webrick and mongrel. How can I do this same thing using Lighty and  
Mongrel?

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [March 7, 2006, 5:51am UTC](https://www.ruby-forum.com/t/lighty-mongrel/54500/2 "2006-03-07T05:51:49Z")

</div>

Joe,

Try out [http://mongrel.rubyforge.org/docs/lighttpd.html](http://mongrel.rubyforge.org/docs/lighttpd.html) for the start of  
my  
docs in this direction. Some advanced PFM at the end you might not  
need.

Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

P.S. This one goes out to technoweenie. PFM == Pure Fucking Magic

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [March 7, 2006, 5:59am UTC](https://www.ruby-forum.com/t/lighty-mongrel/54500/3 "2006-03-07T05:59:46Z")

</div>

Joe wrote:

> On httpd I use ProxyPass and ProxyPassReverse to forward requests to  
> webrick and mongrel. How can I do this same thing using Lighty and  
> Mongrel?

Hey Joe,

Lighty has a really cool feature called Cache Meta Language that lets  
you write write a script that is executed on every request called a  
“power magnet”. Scripts are written in a light-weight language called  
Lua. With a power magnet you can check for the existence of a static  
file and return a “cache hit” if it exists. If it doesn’t exist, return  
a “cache miss” and the request will be forwarded as normal. In addition  
to mod\_proxy, it may be possible to use this with mod\_fcgi as an  
alternative to the check-local/error-handler-404 trick, but I’m not sure  
you would gain anything beyond having a standard way to handle static  
files. The power magnet is also handy for supporting Capistrano’s  
disable\_web task.

Lighty docs on CML:  
[http://lighttpd.net/documentation/cml.html](http://lighttpd.net/documentation/cml.html)

> **[CacheMetaLanguage - Lighttpd - lighty labs](https://redmine.lighttpd.net/projects/lighttpd/wiki/CacheMetaLanguage)**
>
> Redmine

Using CML with proxy to Mongrel and disable\_web support:  
[http://mongrel.rubyforge.org/docs/lighttpd.html](http://mongrel.rubyforge.org/docs/lighttpd.html)

The Lua programming language:

> **[The Programming Language Lua](http://www.lua.org/)**
>
> Official web site of the Lua language

Good luck!

Bradley Taylor

* * *

Rails Machine  
Simplified web application deployment  
[http://railsmachine.com](http://railsmachine.com)

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [March 7, 2006, 12:22pm UTC](https://www.ruby-forum.com/t/lighty-mongrel/54500/4 "2006-03-07T12:22:22Z")

</div>

Since switching to the multiple proxies and mongrels per host, I now  
have about 20 postgres connections per each host that are persisting. Is  
there a way to limit the number of connections? And/or make them  
non-persistant?

Oh, also, does changing the number of processor threads make much/any  
difference when used with Rails? (I read the bit in the docs about how  
Rails isn’t thread-safe and the dispatch call is blocked.)

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [March 7, 2006, 7:12am UTC](https://www.ruby-forum.com/t/lighty-mongrel/54500/5 "2006-03-07T07:12:24Z")

</div>

Wow, coolness :). I’ll have to check out the CML and PFM later.

I added the proxy.balance and proxy.server lines to a couple of my hosts  
in lighty, fired up some mongrels, and everything seems to work fine and  
fast as shitola :).

Joe
