Search code examples
ruby-on-railssubdomainproduction-environmentsubdomain-fu

Setting up Subdomain-Fu in Production Environment?


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.


Solution

  • 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/