views:

111

answers:

2

I'm using the popular subdomain-fu for subdomain functionality in my Rails app. I've watched the Railscast and read everything I could find through google.

In the dev environment, you need to manually add the available subdomains to the /etc/hosts file. I get that. But how does this work in production? This seems to be considered so obvious that nobody mentions it anywhere. But I guess I don't get it.

Clearly, it must be possible to set up a dynamic solution in production or else subdomains couldn't scale at all, but I'm not sure exactly what I need to do. I'm running Apache + Passenger on an Ubuntu box. I've set up a wildcard ServerAlias in my vhost file like this:

ServerAlias *.example.com.

But I'm not sure what else I need to do in order for my subdomains to resolve correctly. Any guidance about the standard approach to this would be much appreciated.

A: 

You'll need to update the DNS records for your domain (most domain providers will provide a simple web interface for doing this). You need to add an A record for each subdomain mapping the name of the subdomain to the IP address of your server.

Ceilingfish
+1  A: 

You'll need to setup a wildcard dns entry to redirect all subdomains to your server(s).

Here's a guide: http://ma.tt/2003/10/wildcard-dns-and-sub-domains/

thomasfedb