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 2 Oct 2007, at 11:04, prism wrote:

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?

If my memory is correct if you prepend service to you routes then
this will have the desired effect (don’t forget to restart your app)
i.e. map.connect ‘service/:controller/:action/:id’

Fred

Still gets the same error:

Routing Error

no route found to match “/service/” with {:method=>:get}

(same happens without trailing slash)

Thanks,
Bjørn

On Oct 2, 12:18 pm, Frederick C. [email protected]

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

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?

No, because if it gets to myapp, it’s too late for it to get to the
other app. You need to fix your RewriteRule.

Sure, my initial thought was that the rule was broken.
But I tried several different ones before just giving up and asking
here. Do you (or does anyone) have an idea of a rule that could work?

In any case, just to be clear, this is how I’d like it to work:

www.myapp.com

points to an Apache server and is rewritten to a load balance cluster
(and this does work, rewrite and all).
In addition to that, I’d like a second (and later on a third),
seperate rails application to run at

www.myapp.com/service/

and to be rewritten to another cluster.

The reason why I ‘need’ a new application is that the /service/
application is encoded with Latin1 and connects to a pre-existing
Interbase db, whereas the root application is encoded with UTF-8 and
connects to MySQL.
/service/ is closely related to the root application, with the same
basic layout for the view, and I’d like it to appear as an integral
part of the site. I can always use subdomains, but I’d rather not.

Here’s the contents of my vhost when it works fine, before adding
anything to do with the /service/ rewrite and cluster:

<VirtualHost *:80>
ServerName myapp.com
ServerAlias www.myapp.com
ServerAlias myapp
DocumentRoot “C:/dev/server/myapp/public”

# ProxyPass / http://localhost:4000/
# ProxyPassReverse / http://localhost:4000
# ProxyPreserveHost on

<Directory “C:/dev/server/myapp/public”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^vmyapp.com$ [NC]
RewriteRule ^(.)$ http://www.myapp.com$1 [R=301,L]
RewriteRule ^/$ /index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.
)$ balancer://myapp_cluster%{REQUEST_URI} [P,QSA,L]

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

ErrorLog logs/myapp_errors_log
CustomLog logs/myapp_log combined

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

Thanks,

Sure, my initial thought was that I had the wrong rule.
After trying a whole set of different rules I just gave up and asked
here.

Do you (or does anyone else) have an idea of a rule that would work?

Just to make it clearer, this is how I’d like it to work:

www.myapp.com

points to an Apache server and is rewritten to a load balance cluster
(works ok).
In addition to that, I’d like a second (and later on a third),
seperate rails application to run at

www.myapp.com/service/

and to be rewritten to another cluster.

The reason why I ‘need’ a new application is that the /service/
application is encoded with Latin1
and connects to a pre-existing Interbase db, whereas the root
application is encoded with UTF-8
and connects to MySQL. It’s also in part because it seems more
maintainable and more secure to
have it spread across like that. I.e. if one ‘module’ goes down, the
rest of the site
is still operational.
To users, the /service/ should appear as an integral part of the site.
I could just use subdomains, but it’d be nicer to have everything as
paths.

Here’s the vhosts file I use (conf\extra\httpd-vhosts.conf):

<VirtualHost *:80>
ServerName myapp.com
ServerAlias www.myapp.com
ServerAlias myapp
DocumentRoot “C:/dev/server/app/myapp/public”

# ProxyPass / http://localhost:4000/
# ProxyPassReverse / http://localhost:4000
# ProxyPreserveHost on

<Directory “C:/dev/server/app/myapp/public”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^myapp.com$ [NC]
RewriteRule ^(.)$ http://www.myapp.com$1 [R=301,L]
RewriteRule ^/$ /index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.
)$ balancer://myapp_cluster%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/(service)/(.*)$
balancer://myapp_service_cluster%{REQUEST_URI}
[P,QSA,L]

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

ErrorLog logs/myapp_errors_log
CustomLog logs/myapp_log combined

<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

Thanks,

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