# Apache/mongrelcluster config for multi (unrelated) sites on

**URL:** <https://www.ruby-forum.com/t/apache-mongrelcluster-config-for-multi-unrelated-sites-on/107112>\
**Category:** Deployment\
**Created:** [June 18, 2007, 9:27am UTC](https://www.ruby-forum.com/t/apache-mongrelcluster-config-for-multi-unrelated-sites-on/107112 "2007-06-18T09:27:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@mjt](https://www.ruby-forum.com/u/mjt)\
**Post date:** [June 18, 2007, 9:27am UTC](https://www.ruby-forum.com/t/apache-mongrelcluster-config-for-multi-unrelated-sites-on/107112/1 "2007-06-18T09:27:12Z")

</div>

Hi all,

I am attempting to setup two disparate sites on a single in-house  
host.  
I have the first one up and going OK and dont want to bend it while  
bringing up a second.

Is this apache / mongrel config appropriate ? Currently the Proxy line  
for the mongrel stuff is  
\<Proxy balancer://mongrel\_cluster\>

I am assuming that I can change the name(s) to this  
\<Proxy balancer://app\_one\_cluster\>  
\<Proxy balancer://app\_two\_cluster\>

cheers  
mjt

--------8\<-------------

# 

# Virtual Site ONE mongrel ports at 5000+

# 

\<VirtualHost \*:80\>  
ServerName app\_one.com  
DocumentRoot /var/rails/app\_one/current/public  
\<Directory “/var/rails/app\_one/current/public”\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all

# Configure mongrel\_cluster

\<Proxy balancer://app\_one\_cluster\>  
BalancerMember [http://127.0.0.1:5000](http://127.0.0.1:5000)  
BalancerMember [http://127.0.0.1:5001](http://127.0.0.1:5001)  
BalancerMember [http://127.0.0.1:5002](http://127.0.0.1:5002)  
  
RewriteEngine On

# If there is a maintenence.html file in your

# public dir all requests will get rerouted to

# this file.

RewriteCond %{DOCUMENT\_ROOT}/maintenance.html -f  
RewriteCond %{SCRIPT\_FILENAME} !maintenance.html  
RewriteRule ^.\*$ /maintenance.html [L]

# Rewrite index to check for static index.html

RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached pages with .html extentions

RewriteRule ^([^.]+)$ $1.html [QSA]

# All dynamic requests get sent to the mongrel cluster

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
RewriteRule ^/(.\*)$ balancer://app\_one\_cluster%{REQUEST\_URI}  
[P,QSA,L]

# Deflate

AddOutputFilterByType DEFLATE text/html text/plain text/xml  
BrowserMatch ^Mozilla/4 gzip-only-text/html  
BrowserMatch ^Mozilla/4.0[678] no-gzip  
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html  
ErrorLog logs/app\_one\_error\_log  
CustomLog logs/your\_access\_log combined

# 

# Virtual Site TWO mongrel ports at 5020+

# 

\<VirtualHost \*:80\>  
ServerName app\_two.com  
DocumentRoot /var/rails/app\_two/current/public  
\<Directory “/var/rails/app\_two/current/public”\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all

# Configure mongrel\_cluster

\<Proxy balancer://app\_two\_cluster\>  
BalancerMember [http://127.0.0.1:5020](http://127.0.0.1:5020)  
BalancerMember [http://127.0.0.1:5021](http://127.0.0.1:5021)  
BalancerMember [http://127.0.0.1:5022](http://127.0.0.1:5022)  
  
RewriteEngine On

# If there is a maintenence.html file in your

# public dir all requests will get rerouted to

# this file.

RewriteCond %{DOCUMENT\_ROOT}/maintenance.html -f  
RewriteCond %{SCRIPT\_FILENAME} !maintenance.html  
RewriteRule ^.\*$ /maintenance.html [L]

# Rewrite index to check for static index.html

RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached pages with .html extentions

RewriteRule ^([^.]+)$ $1.html [QSA]

# All dynamic requests get sent to the mongrel cluster

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
RewriteRule ^/(.\*)$ balancer://app\_two\_cluster%{REQUEST\_URI}  
[P,QSA,L]

# Deflate

AddOutputFilterByType DEFLATE text/html text/plain text/xml  
BrowserMatch ^Mozilla/4 gzip-only-text/html  
BrowserMatch ^Mozilla/4.0[678] no-gzip  
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html  
ErrorLog logs/app\_two\_error\_log  
CustomLog logs/your\_access\_log combined

---

<div class="post-metadata">

**Author:** ![mjt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@mjt](https://www.ruby-forum.com/u/mjt)\
**Post date:** [June 18, 2007, 10:12am UTC](https://www.ruby-forum.com/t/apache-mongrelcluster-config-for-multi-unrelated-sites-on/107112/2 "2007-06-18T10:12:16Z")

</div>

It looks good to me which is mostly the same as this one I’m using  
(generated by the railsmachine gem):

\<VirtualHost \*:80\>  
ServerName prototype.mysite.info  
ServerAlias www.prototype.mysite.info  
DocumentRoot /var/www/apps/mysite/current/public

\<Directory /var/www/apps/mysite/current/public\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all

# Configure mongrel\_cluster

\<Proxy balancer://mysite\_cluster\>  
BalancerMember [http://127.0.0.1:8100](http://127.0.0.1:8100)  
BalancerMember [http://127.0.0.1:8101](http://127.0.0.1:8101)

RewriteEngine On

# Prevent access to .svn directories

RewriteRule ^(.\*/)?.svn/ - [F,L]  
ErrorDocument 403 “Access Forbidden”

# Check for maintenance file and redirect all requests

RewriteCond %{DOCUMENT\_ROOT}/system/maintenance.html -f  
RewriteCond %{SCRIPT\_FILENAME} !maintenance.html  
RewriteRule ^.\*$ /system/maintenance.html [L]

# Rewrite index to check for static

RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached page

RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
RewriteRule ^/(.\*)$ balancer://mysite\_cluster%{REQUEST\_URI} [P,QSA,L]

# Deflate

AddOutputFilterByType DEFLATE text/html text/plain text/xml  
BrowserMatch ^Mozilla/4 gzip-only-text/html  
BrowserMatch ^Mozilla/4.0[678] no-gzip  
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

ErrorLog logs/prototype.mysite.info-error\_log  
CustomLog logs/prototype.mysite.info-access\_log combined

bye  
Luca

2007/6/18, mjt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
