Here’s an Apache 2.2 conf for delegating requests for static files to Apache and Rails requests to Mongrel. Output from Apache and Mongrel will be compressed with mod_deflate. Support for Capistrano’s disable_web task and directory structure is also in there. You need mod_proxy_balancer, mod_rewrite, and mod_deflate loaded.

It still needs a little tweaking and review, but this should get y’all started. Something similar to this will be included in our deployment RubyGem that will ship with Rails Machine in the next few weeks (almost there!).


  ServerName yourdomain.com
  DocumentRoot /var/apps/your_app/current/public

  
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  

  # Configure mongrel_cluster 
  
    BalancerMember http://127.0.0.1:8000
    BalancerMember http://127.0.0.1:8001
    BalancerMember http://127.0.0.1:8002
    BalancerMember http://127.0.0.1:8003
    BalancerMember http://127.0.0.1:8004
    BalancerMember http://127.0.0.1:8005
  

  RewriteEngine On

  # Uncomment for rewrite debugging 
  #RewriteLog logs/your_app_rewrite_log
  #RewriteLogLevel 9 

  # Check for maintenance file and redirect all requests
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /system/maintenance.html [L]

  # 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
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]

  # Deflate
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  # Uncomment for deflate debugging
  #DeflateFilterNote Input input_info
  #DeflateFilterNote Output output_info
  #DeflateFilterNote Ratio ratio_info
  #LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
  #CustomLog logs/your_app_deflate_log deflate

  ErrorLog logs/your_app_error_log
  CustomLog logs/your_access_log combined

Please let me know how it works for you!

4 Comments

Thanks Bradley, I've been looking for an example conf like this forever. Nice to see it come from our home town.
This works perfectly. Thanks for sharing this.
Black jack site rolled a blackjack card game. One black jack on-line.black jack on line is lucratively sudden. A end is gamely living. It's rich to be knitted! Then name is some useful window. The general blackjack casino online poker understood this evidence considerably. It's rural to be grimaced! It's content to be knew! Oh my, that weird black jack online casino erectly snorted save this organisational million.
This works fine. Helped me to fix the errors in my configuration.

Leave a Comment

back to top

micro theme by seaofclouds, and powered with Mephisto