Friday, April 18, 2008

apache2 and mongrel cluster on debian

Enable apache2 proxy
$ sudo a2enmod proxy proxy_http proxy_balancer

Configure Proxy in a virtual host
/etc/apache2/site-enabled/default add
DocumentRoot "RailsApp/public"
    # even only RailsApp also work

ProxyPass / balancer://localhost/
ProxyPassReverse / balancer://localhost/
< proxy balancer://localhost/ >
    BalanceMember http://localhost:3000
    BalanceMember http://localhost:3001
    BalanceMember http://localhost:3002
< /proxy >

Then set mongrel cluster
$ sudo gem install mongrel_cluster
$ cd RailsApp
$ mongrel_rails cluster::configure -e development -p 3000 -N 3
    # write config/mongrel_cluster.yml

$ mongrel_rails cluster::start

Final, restart apache2 and it work.


1 comment:

gabs said...

Thanks for this, help me out :)
Initially It did not work, but found the typo: It's BalancerMember, not BalanceMember..