I'm running Ubuntu 10.04 with apache, rails, mysql, etc.
My rails site is running at www.example.com. I'm intending to use named-based virtual hosting and I have a virtual hosts file configured/enabled for www.example.com. My site is hosted on Amazon EC2.
The problem is that if I set up a new DNS record -- say test.example.com -- and browse to that, my site www.example.com is served up! That's without configuring any new virtual hosts.
And the same is true if I go to my DNS records and define test2.example.com, etc. Without touching my server, these new URLs serve up my website.
That's not what I want! I want to use name-based virtual hosting and host different sites for each subdomain.
Where could my problem be?
Here's my virtual hosts file:
ServerSignature Off
ServerTokens Prod
#NameVirtualHost *:80 - this is defined in a default config file already.
<VirtualHost *:80>
ServerAdmin [email protected]
UseCanonicalName On
ServerName www.example.com
DocumentRoot /home/ubuntu/example/public
ErrorLog /home/ubuntu/example/log/error.log
<Directory /home/ubuntu/example/public/>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
If there aren't any matching virtual hosts to use, apache will use what it considers to be the default virtual host. If you want a blank page to display, set that as the first virtual host, then define your www.example.com entry afterwards.