Hi,
A lot of us are now using Apache 2.2 + mod_rewrite to forward incoming
and uncached requests to a Mongrel Cluster.
That was fine until REST arrived.
With the current recommended configuration, Apache works as follows:
a. There is a static file avaliable in the file system => send it
(regardless to the request method)
b. There is none, forward request to Mongrel Cluster
However, with RESTful Rails, we have urls such as /articles/1 which
should be cached only when we GET it, not when we POST or PUT it. What
if we want to update an article and Apache sends us the static HTML file
instead of forwarding our request to Rails?
Here is the solution I suggest:
Replace in apache configuration file:
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://MyCluster%{REQUEST_URI} [P,QSA,L]
By
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_METHOD} !^GET*
RewriteRule ^/(.*)$ balancer://MyCluster%{REQUEST_URI} [P,QSA,L]
What do you thing about that?
on 31.08.2006 18:36
on 31.08.2006 23:15
> RewriteCond %{REQUEST_METHOD} !^GET* > RewriteRule ^/(.*)$ balancer://MyCluster%{REQUEST_URI} [P,QSA,L] > > What do you thing about that? > Does it work? Seems like it should. Mongrel has something similar built in actually (not that it'll help in this case). -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com
on 01.09.2006 10:13
Yes it should work. But I am looking for people who know more than I do about Apache and REST to confirm that this is or is not a good idea... Someone?
on 25.03.2008 17:02
I spent loooong time to locate the problem, and then your solution saved me from wasting more. Thanks a lot. On Sep 1 2006, 12:36 am, Nauhaie None <rails-mailing-l...@andreas-