Ignore path

Hi,

I’m trying to rewrite a path to a different application with Apache.

My Apache Rewrite rule is

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

My other rewrites for this site work, but the problem (and why I’m
asking here and not on an Apache forum) is that I’m curious if it will
ever be rewritten correctly, because at the moment, it’s passed to
myapp, which then tries to find a controller named “service”.

Is there any way for myapp to ‘ignore’ the /service/ path? In
routes.rb maybe?

Thanks,
Bjørn

On 10/2/07, prism [email protected] wrote:

I’m trying to rewrite a path to a different application with Apache.

? 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 balancer://service_cluster>
BalancerMember http://localhost:4010
BalancerMember http://localhost:4011
BalancerMember http://localhost:4012

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 :slight_smile:

FWIW,

Hassan S. ------------------------ [email protected]

Thanks Hassan. I still get the same error though! :confused:
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 “C:/dev/server/app/myapp_service/public”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all


<Proxy balancer://myapp_cluster>
BalancerMember http://localhost:4000
BalancerMember http://localhost:4001
BalancerMember http://localhost:4002

<Proxy balancer://myapp_service_cluster>
BalancerMember http://localhost:4010
BalancerMember http://localhost:4011
BalancerMember http://localhost:4012

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. :wink:

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

Example:

RewriteCond %{REQUEST_URI} ^/service.*
RewriteRule .* - [L]

but no go. I’ve also tried doing that within the vhosts.conf file.

Thanks,
Bjørn

On Oct 3, 2:05 am, “Hassan S.” [email protected]

On 10/3/07, prism [email protected] wrote:

Thanks Hassan. I still get the same error though! :confused:
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.

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 :slight_smile:

But I would try swapping the ProxyPass stuff first…

HTH,

Hassan S. ------------------------ [email protected]

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. :wink:

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

On Oct 3, 6:31 pm, “Hassan S.” [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs