Making today worse so tomorrow seems better.
Wildcard DNS and Rails
The most common Rails config wants a separate hostname for each application. If you tend to create new ones frequently, this can mean a lot of running back and forth to your DNS config. At best this means waiting for the changes to propagate, at worst it could mean waiting for corporate IT to get around to it.
Luckily, in addition to normal names, DNS allows you to create “wildcard” records that match any name not otherwise defined.
We setup each hostname with their own wildcard by default, so that foo.hostname is always an alias (CNAME) for hostname.
An example from our bind zone file:
sprocket IN A 69.27.234.180
*.sprocket IN CNAME sprocket
This means that if I want to deploy my new app, The Awesomator, I can use the hostname ‘awesomator.sprocket.slackworks.com’ without having to change anything in DNS.
Then I drop my virtual host config awesomator.conf file, largely stolen from Coda Hale’s config , into Apache’s config directory (/etc/apache2/sites-available/ on Debian, /etc/httpd/conf.d/ on Red Hat). An Apache reload and a few mongrels later and I’m up and running on my new hostname.
- About
- Technology, programming, the interwebs and other topics by members of the slackworks community.
- Contributors
- All Posts
-
- Aug 05 2009 Using New Relic add_method_tracer with Class methods
- Jun 30 2009 Estimating Key Collisions (Birthday Problem)
- Jun 29 2009 The Blarg is Back!
- Jul 23 2008 JNDI with Rails
- Jul 06 2008 JRuby Service in Rails
- May 16 2008 Wildcard DNS and Rails
- Jan 30 2008 Sprint Error "911" and the "Download Domain"
- Jan 16 2008 Getting a Good View of Your Couch
- Jan 12 2008 Bring Selenium to the integration party
- Jan 12 2008 Bj Makes Attachment_fu Happy
- Jan 03 2008 Restore Finder magic to a sparsebundle directory
- Dec 18 2007 First Post
0 comments