[Mongrel] Apache rewrites with mongrel

Guido Holz lists at ruby-forum.com
Mon Jun 16 05:47:23 EDT 2008

I´m knew to rewrites on apache in combination with mongrelcluster.
It´s urgend for me, because the server has an loadaverage about 10

Ok so I´m using 3 mongrel-server on an mongrelcluster. The Loadbalancer
ist apache
I think, that my rewrites are not correct. Please can anybody check my
rewrites ?

That´s in my /etc/apache2/conf.d/rails.proxy_cluster.conf
<Proxy balancer://mongrel_cluster>

that´s in my /etc/apache2/sites-enabled/000-rails

        RewriteEngine On

        # Deflate
        AddOutputFilterByType DEFLATE text/html text/plain text/css
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4.0[678] no-gzip
        BrowserMatch bMSIE !no-gzip !gzip-only-text/html

        ProxyPass /images !
        ProxyPass /stylesheets !
        ProxyPass /javascripts !

        Alias /images /var/www/rails/myApp/current/public/images
        Alias /stylesheets
        Alias /javascripts

        RewriteLog /var/log/apache2/rails-rewrite.log

And last not lease my .htaccess in public

AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

AddDefaultCharset UTF-8
RewriteEngine On

RewriteRule ^01,([0-9]*).html$ balancer://mongrel_cluster/shop/event/$1
RewriteRule ^01,([a-zA-Z0-9]*),([0-9]+).html$
balancer://mongrel_cluster/shop/search/$2?startnumber=$1 [P,L]

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

the rewrite for static-sites is correct?
I saw this lines on a howto

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

if I call www.myApp.com/shop (redirected internaly by globalize to
en/shop )
then I`ll get the cached page under public/en/shop.html

but when I call www.myApp.com/shop again then I can see in my logfiles

Processing ShopController#index (for xx.xxx.xxx.xx at 2008-06-16
11:46:04) [GET]
  Session ID: 4cbe53c829bdc7ef9ceb81cc6f0fe1fa
  Parameters: {"action"=>"index", "controller"=>"shop", "locale"=>"en"}
Rendering template within layouts/shop
Rendering shop/index
Completed in 0.17766 (5 reqs/sec) | Rendering: 0.09954 (56%) | DB:
0.00000 (0%) | 200 OK [http://www.myApp.com/en/shop/]

I think something went wrong with my rewrites.

thanks for helping.

cheers guido
Posted via http://www.ruby-forum.com/.

More information about the Mongrel-users mailing list