Posted
3 July 2009 @ 9am

Tagged
, , , , ,

Share and Enjoy
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Digg
  • Twitter
  • Reddit
  • MySpace
  • Technorati
  • StumbleUpon
  • Tumblr
  • Slashdot
  • email
  • Print

deploy:web:disable and Dreamhost

Following on the heels of Twitter on your maintenance page, the other piece of custom setup I needed for this solution to work was making the site swallow all incoming requests while disabled in order to show the maintenance page.  In the past on sites using Nginx+thin/mongrel the setup has been in the nginx configuration code.  At Dreamhost, where I have my Rails projects (and this site), the setup uses Apache+passenger.  And you don’t have access to the virtual host section of the Apache setup to do the configuration there.

Use .htaccess

The solution was to use .htaccess.  Put it in your public directory.  Check it into source control.  When you deploy your app, the configuration will go with it.

Make a special rule for images, if you want ‘em

My custom maintenace page links to a couple of images (the logo and a background gradient).  The rest of the page I can encapsulate in the html iteself (css and javascript), so there’s no need for special rules about what Apache will choose to server and what it won’t.  But to avoid Apache serving up the maintenance.html page for all your images, you need a special rule.

Below, the complete .htaccess:

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteCond %{REQUEST_URI} !^/images/
RewriteRule ^.*$ /system/maintenance.html [L]

Useful additional links


blog comments powered by Disqus
Twitter on your maintenance page Rails running in script/console?