hassan
(Hassan Schroeder)
October 3, 2007, 12:05am
1
? Not sure why you're trying to use mod_rewrite here.
Your VirtualHost can include something like this:
ProxyPass /service/ balancer://service_cluster/
ProxyPassReverse /service/ balancer://service_cluster/
ProxyPass / balancer://default_cluster/
ProxyPassReverse / balancer://default_cluster/
<Proxy balancer://default_cluster>
BalancerMember http://localhost:4000
BalancerMember http://localhost:4001
BalancerMember http://localhost:4002
</Proxy>
<Proxy balancer://service_cluster>
BalancerMember http://localhost:4010
BalancerMember http://localhost:4011
BalancerMember http://localhost:4012
</Proxy>
Add:
ActionController::AbstractRequest.relative_url_root = "/service"
::to your /service/ environment.rb and you should be set.
Or at least it seems to work for me
FWIW,
praxis
(praxis)
October 3, 2007, 10:05am
2
Thanks Hassan. I still get the same error though!
My vhosts.conf looks like this now:
<VirtualHost *:80>
ServerName myapp.com
ServerAlias www.myapp.com
ServerAlias myapp
DocumentRoot "C:/dev/server/app/myapp/public"
ProxyPass / balancer://myapp_cluster/
ProxyPassReverse / balancer://myapp_cluster/
ProxyPass /service/ balancer://myapp_service_cluster/
ProxyPassReverse /service/ balancer://myapp_service_cluster/
<Directory "C:/dev/server/app/myapp/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "C:/dev/server/app/myapp_service/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<Proxy balancer://myapp_cluster>
BalancerMember http://localhost:4000
BalancerMember http://localhost:4001
BalancerMember http://localhost:4002
</Proxy>
<Proxy balancer://myapp_service_cluster>
BalancerMember http://localhost:4010
BalancerMember http://localhost:4011
BalancerMember http://localhost:4012
</Proxy>
The relative_url_root thing was put into the /service/ environment.rb.
About the rewrites, one reason IIRC is to allow Apache to handle the
static content?
Whether or not my rewrites actually do that is another question.
I've also tried, in the root application public/.htaccess file, to do:
# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain
requests
hassan
(Hassan Schroeder)
October 3, 2007, 4:31pm
3
Thanks Hassan. I still get the same error though!
My vhosts.conf looks like this now:
ProxyPass / balancer://myapp_cluster/
ProxyPassReverse / balancer://myapp_cluster/
ProxyPass /service/ balancer://myapp_service_cluster/
ProxyPassReverse /service/ balancer://myapp_service_cluster/
I think the order of the above is significant -- the more specific
reference should come first, because anything will match to /.
Have you looked at your mongrel logs? I'm betting the Routing
Error is coming from a mongrel in your my_app cluster, /not/
the myapp_service_cluster.
</VirtualHost>
<Proxy balancer://myapp_cluster>
BalancerMember http://localhost:4000
BalancerMember http://localhost:4001
BalancerMember http://localhost:4002
</Proxy>
<Proxy balancer://myapp_service_cluster>
BalancerMember http://localhost:4010
BalancerMember http://localhost:4011
BalancerMember http://localhost:4012
</Proxy>
BTW, I think the Proxy elements should be inside the VirtualHost
element, though that's probably not the cause of this problem...
About the rewrites, one reason IIRC is to allow Apache to handle the
static content?
Ah, well, that's totally different. I never do apps with enough static
content to bother
But I would try swapping the ProxyPass stuff first...
HTH,
praxis
(praxis)
October 4, 2007, 8:40am
4
Well that helped. =)
Probably because of the order like you said.
The routing error would've had to be in the root app since I haven't
had a /service/ app running most of the time.
Adding the rewrites again underneath, it reverts back to the old
behaviour, but this isn't being deployed for another couple of months
so I think I'll drop it for now.
Thanks again!,
Bjørn