Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a virtual host configured to run a Ruby on Rails app on Apache and Passenger this way:

 <VirtualHost *:80>
  ServerAdmin account@gmail.com

  ServerName staging.domain.co
  ServerAlias *.doamin.co
  DocumentRoot /home/ubuntu/staging/current/public

So staging.domain.co, site1.domain.co, site2.domain.co are working find, this is for staging environment. Now I need to add the production environment on the same server. I wold like to add the production environment but I am not sure how to do it. The VPS is running on EC2. Even by using two different servers, there is the issue of the DNS server resolving all subdomains to the current VPS IP. I think the only solution is to use different second level domains:

staging
  anotherdomain.co

production
  domain.co

What do you think?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If you are using name-based virtualhosts in apache, DNS has little to do with it; a million hostnames could end up at your IP and apache would still be able to serve a million distinct web sites.

That said, the problem with your setup is the line

ServerAlias *.domain.com

You want to remove that and replace it with the actual subdomains in use for staging and/or production.

Also note that the first-listed virtualhost is by definition the default one in apache.

share|improve this answer
    
I am using ServerAlias *.domain.com because the subdomain is created dynamically by the app (multi tennant app). –  rtacconi Feb 27 '12 at 16:30
    
That's entirely irrelevant; it's horribly bad setup and there are at least 2 better alternatives. –  adaptr Apr 18 '12 at 15:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.