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?
Best Answer
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
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.