Running Redmine behind Mongrel#

http://www.redmine.org/wiki/redmine/HowTo_run_Redmine_with_a_Mongrel_cluster

Mongrel is a fast HTTP library and server for Ruby that is intended for hosting Ruby web applications of any kind using plain HTTP rather than FastCGI or SCGI. Throughout this HowTo we will assume the following:

  • Redmine is located in /var/www/redmine
  • apache2 is used as the load balancing proxy in front of the cluster

Setting up the mongrel cluster#

Install the required gems:

sudo gem install mongrel mongrel_cluster daemons

Configure the mongrel cluster for Redmine:

cd /var/www/redmine
sudo mongrel_rails cluster::configure -e production -p 8000 -N 3 -c /var/www/redmine --user www-data --group www-data

And start the cluster:

sudo mongrel_rails cluster::start

This will start 3 mongrel servers listening on ports 8000, 8001, and 8002. You should be able to access Redmine using one of these ports (eg. http://localhost:8000).

Setting up the load balancer#

Add a virtual host to your Apache configuration. Here is a minimalistic configuration that will serve static content by apache and send dynamic requests to the cluster:

<VirtualHost *>
  ServerName redmine.yourdomain
  DocumentRoot /var/www/redmine/public
  <Directory "/var/www/redmine/public">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
  <Proxy balancer://redmine_cluster>
    Order allow,deny
    Allow from all
    BalancerMember http://127.0.0.1:8000
    BalancerMember http://127.0.0.1:8001
    BalancerMember http://127.0.0.1:8002
  </Proxy>
  RewriteEngine On
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://redmine_cluster%{REQUEST_URI} [P,QSA,L]
</VirtualHost>

Restart apache and you're done.


Ruby - Networking