Setting 503 response code for Apache default virtual host

I know I promised my next post would be a tutorial on Chef, but this is kinda related. When new Rails servers are spinning up, I want Apache to respond to any requests with 503, both for SEO purposes in case I get my DNS wrong, and to tell load balancers that the node isn’t ready yet. It took me a while to grok the Apache docs to understand how to do this, as it is a bit counterintuitive (see the bit headed “‘redirect|R [=code]’ (force redirect)”). Please let me know if there’s a better way that perhaps doesn’t involve turning on RewriteEngine.

I changed my /etc/apache2/sites-available/000-default to be the following. This acts as the fallback when no other virtual hosts match the hostname used in the request. It gives the default Apache page, which is horrible. I’m sure you could fix it to point at something nice by using some more directives.