There seems to be a ton of documentation out there, but I can’t seem
to figure out how to get this to work. I’ve got two rails apps: app1,
which should be available at http://www.domain.com and app2 which
should be available at http://sub.domain.com. Both apps should be
served up by a mongrel cluster (app1 running on ports 8000-8002 and
app2 running on 9000-9002). App1 is working like a charm, however when
I go to http://sub.domain.com, I get app1 instead of app2. As a side
note, if I replace app2 with a static html page and take rails/mongrel
out of the equation entirely, the subdomain works just like it’s
supposed to.
My gut tells me it’s how I’ve got my virtual host files set up
(specifically the RewriteCond/RewriteRule parts). Could someone please
point me in the right direction? Thanks!
-Brian
Physical location:
app1: /var/www/app1
app2: /var/www/app2
/etc/apache2/sites-available/default:
NameVirtualHost *
<Proxy balancer://mongrel_cluster>
BalancerMember http://localhost:8000
BalancerMember http://localhost:8001
BalancerMember http://localhost:8002
<VirtualHost >
ServerName domain.com
DocumentRoot /var/www/app1/public/
.
.
.
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.)$ balancer://mongrel_cluster%{REQUEST_URI}
[P,QSA,L]
/etc/apache2/sites-available/app2:
NameVirtualHost *
<Proxy balancer://mongrel_cluster>
BalancerMember http://localhost:9000
BalancerMember http://localhost:9001
BalancerMember http://localhost:9002
<VirtualHost >
ServerName sub.domain.com
DocumentRoot /var/www/app2/public/
.
.
.
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.)$ balancer://mongrel_cluster%{REQUEST_URI}
[P,QSA,L]