[Mongrel] what should be correct .conf file for being served by apache for static content

Jens Kraemer kraemer at webit.de
Sat Sep 9 09:36:31 EDT 2006

On Sat, Sep 09, 2006 at 06:44:13PM +0530, hemant wrote:
> "Also, if you stop Mongrel, then try to serve one of your static files,
> you can tell for sure whether Apache is serving it or not"
> To all those folks out there...who are using ProxyPass and ProxyPassReverse
> statements for forwarding requests to the proxy....the above tests fails,
> and hence....I am not sure, if Apache serves static pages, if you are using
> ProxyPass and ProxyPassReverse.

To conditionally forward requests to Mongrel you should use url
rewrite rules instead of ProxyPass* directives:

# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA] 

# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster
# translated: "if this request does not point to a file we have lying
# around in our file system (the !-f part), then go ahead and let 
 #Mongrel do it's job"
RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]

You can achieve the same with the Proxy* rules by explicitly excluding
several directories where static files reside from being proxied, but
the rewrite approach is much more elegant, imho.

The snippet has been taken from the quite complex apache config example
at http://mongrel.rubyforge.org/docs/apache.html


webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       kraemer at webit.de
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66

More information about the Mongrel-users mailing list