views:

962

answers:

2

Hi Folks, I'm fairly new to ruby on rails and web development. Here is my setup which I followed from this link http://tonyrose023.blogspot.com/2007/01/multiple-rails-apps-with-mongrel.html I run multiple rails applications on Apache2 with Mongrel clusters.

http://services.abc.edu/app1 http://services.abc.edu/app2 http://services.abc.edu/app3

This is what my 'virtual host' (/etc/apache2/sites-availabe/services.abc.edu) file looks like

--------------
<Proxy balancer://app1> 
BalancerMember http://services.abc.edu:8000 
BalancerMember http://services.abc.edu:8001 
BalancerMember http://services.abc.edu:8002
Order deny,allow
Deny from all
Allow from all
</Proxy>

<Proxy balancer://app2>
BalancerMember http://services.abc.edu:8004
BalancerMember http://services.abc.edu:8005
Order deny,allow
Deny from all
Allow from all
</Proxy>

<Proxy balancer://app3>
BalancerMember http://services.abc.edu:8006
BalancerMember http://services.abc.edu:8007
Order deny,allow
Deny from all
Allow from all
</Proxy>



<VirtualHost *:80>
    ServerName services.abc.edu
    DocumentRoot /home/joe/projects/app1/public


<Directory "/home/joe/projects/app1/public"> 
Options FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 

<Directory "/home/joe/projects/app2/public"> 
Options FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 

<Directory "/home/joe/projects/app3/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

RewriteEngine On 


# 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://mongrel_cluster%{REQUEST_URI} [P,QSA,L] 

RewriteRule ^/app1(.*)$ balancer://app1%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/app2(.*)$ balancer://app2%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/app3(.*)$ balancer://app3%{REQUEST_URI} [P,QSA,L]

</VirtualHost>
-----------------------------------------

My questions are

1) If anybody can comment on my setup and offer any suggestions would be great.

2) As you can see I have one DocumentRoot, although right now all the 3 apps work since they use same images but I think in the future I need to have DocumentRoot for each app

3) I need to get the apps running securely so I need to make this run with SSL (port 443) and I need some help with making it run with SSL. Any pointers would be helpful since I never installed a cert. I created the csr and the key and I have the cert with me. I'm researching on what are the next steps.

Thanks!

+5  A: 

I would advise you to look into Passenger. It's really easy to set up, lets Rails apps share memory, removes the burden of managing a cluster of mongrels and requires virtually no configuration. All you need are a special 'config.ru' file with a RackUp config and a DocumentRoot pointing to RAILS_ROOT/public set in Apache.

The problem with running multiple apps in mongrel is that you need a seperate mongrel instance for each of them.

As for your SSL question, I have found it really easy to set up SSL for some parts of my sites in Nginx. I don't remember how to do it in Apache, but there are most likely some good howtos out there.

Aram Verstegen
+100 for Passsenger ... it simplifies the deployment process immensely. I've moved 5 production Rails systems over to use Passenger rather than Mongrel and it is awesome.
Toby Hede
Thanks for your answer. I have a important project which is coming up in the next few weeks and I don't want to mess up this configuration since its pretty much working right now. But I would like to look into Passenger after my project. Thanks!