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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 2 Oct 2007, at 11:04, prism wrote:> > 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? >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> > Thanks, > Bjørn > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On 2 Oct 2007, at 11:04, prism wrote:
>
>
>
>
>
> > 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?
>
> 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
>
>
>
> > Thanks,
> > Bjørn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 10/2/07, prism <volition1980-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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?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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
</Directory>
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
</VirtualHost>
<Proxy balancer://myapp_cluster>
BalancerMember http://localhost:4000
BalancerMember http://localhost:4001
BalancerMember http://localhost:4002
</Proxy>
Thanks,
Bjørn
On Oct 2, 9:59 pm, "Bob Showalter"
<showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On 10/2/07, prism
<volition1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
>
>
>
>
>
>
> > 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?
>
> 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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
</Directory>
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
</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>
Thanks,
Bjørn
On Oct 2, 9:59 pm, "Bob Showalter"
<showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 10/2/07, prism <volition1980-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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> <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, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
#
# 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 Schroeder"
<hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On 10/2/07, prism
<volition1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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>
> BalancerMemberhttp://localhost:4000
> BalancerMemberhttp://localhost:4001
> BalancerMemberhttp://localhost:4002
> </Proxy>
>
> <Proxy balancer://service_cluster>
> BalancerMemberhttp://localhost:4010
> BalancerMemberhttp://localhost:4011
> BalancerMemberhttp://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,
> --
> Hassan Schroeder ------------------------
hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 10/3/07, prism <volition1980-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Oct 3, 6:31 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 10/3/07, prism <volition1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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> > > BalancerMemberhttp://localhost:4000 > > BalancerMemberhttp://localhost:4001 > > BalancerMemberhttp://localhost:4002 > > </Proxy> > > <Proxy balancer://myapp_service_cluster> > > BalancerMemberhttp://localhost:4010 > > BalancerMemberhttp://localhost:4011 > > BalancerMemberhttp://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, > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---