DNS/Apache subdomain confusion
I have a basic question about whether my apache config is setup correctly on one of my linodes. We have a domain that is currently hosted on mediatemple but we are forwarding subdomains from that domain to linode.
So our mediatemple DNS config is like this:
A records for:
books.example.com -> [IP OF MY LINODE]
events.example.com -> [IP OF MY LINODE]
Then on the linode I don't have specific DNS entries just the following apache configs:
# /usr/sbin/apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server books.example.com (/etc/apache2/sites-enabled/books.example.com:1)
port 80 namevhost books.example.com (/etc/apache2/sites-enabled/books.example.com:1)
port 80 namevhost events.example.com (/etc/apache2/sites-enabled/events.example.com:1)
[ snip ... ]
Syntax OK
and my configs that are symlinked in sites-enabled:
# cat books.example.com
<virtualhost *:80="">ServerAdmin admin@example.com
ServerName books.example.com
ServerAlias books.example.com
DocumentRoot /srv/www/books.example.com/public_html/
ErrorLog /srv/www/books.example.com/logs/error.log
CustomLog /srv/www/books.example.com/logs/access.log combined
<directory>Options FollowSymLinks
AllowOverride All</directory></virtualhost>
# cat events.example.com
<virtualhost *:80="">ServerAdmin admin@example.com
ServerName events.example.com
ServerAlias events.example.com
DocumentRoot /srv/www/eventssite/public_html/
ErrorLog /srv/www/eventssite/logs/error.log
CustomLog /srv/www/eventssite/logs/access.log combined
<directory>Options FollowSymLinks
AllowOverride All</directory></virtualhost>
Now the issue is that books.example.com returns the site at events.example.com and thing generally are a little glitchy. We set up the DNS for this about 18 hours ago. Is it just DNS propagation or is my configuration incorrect?
Please advise, I don't really know that much about DNS configurations… DO I need to modify my /etc/hosts file for example?
Thanks!
- J
3 Replies
You can check DNS with dig +trace books.example.com - this will bypass your ISP's nameservers and do a lookup starting at the DNS root. Modifying your /etc/hosts only changes what your local machine sees, and probably won't be any help.
If your default virtual server is DocumentRoot /srv/www/books.example.com/public_html/, and events.example.com is in the hosts file to resolve to the IP address of the server, then apache fails to pick up on the fact that the request comes from events.example.com and instead assumes it was a request made directly to the IP address of the server, which causes it to use the default virtual site.
You may wish to remove events.example.com from /etc/hosts if it is in there, and see if this makes a difference. If nothing I have said makes sense, it may be useful to paste us the hosts file.