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 website, example.tld. The DNS has an A record for example.tld that points to 1.2.3.4.

Is there any difference (as far as Apache is concerned/configured) whether a sub-domain (www.example.tld) is an A record for 1.2.3.4 or a CNAME for example.tld?

From what I understand, the way the IP gets resolved is separate from the actual HTTP request so how Apache can differentiate between the two, and why/when it matters?

I can't show the Apache config but assume it works well with one case but not the other.

Edit: I handle the DNS side and I have a client who says their hosting provider is insisting that their sub-domain (www.example.tld) won't work unless the sub-domain is defined as a CNAME (as opposed to a A / host record.) I don't see why this matters since everything resolves to the same IP but I don't know Apache, so any edge cases, exceptions, whatever to this rule?

The client is stuck between both sides saying the other is wrong. If I'm in the wrong, I'd like to understand why (and just to reiterate, I don't know Apache) so I won't make the same mistake again.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Apache doesn't see any difference but a web application running in Apache might. I know that the web application that the company I work for runs does do DNS requests when you are configuring your account and expects to see a CNAME.

If your client has been told it must be a CNAME, that could be the reason.

share|improve this answer
add comment

Apache won't even read this dns entry. Only clients.
When a client make a request to a web server, it send a request containing the name of the desired website. When the web server receive it, he just read the name of the desired site to know what to send back.

You can even configure Apache to serve a dummy facebook.com
You modify your client dns to point facebook.com to your when server, and this is YOUR apache which will answer to your browser. Even if your web server dns is not tricked, because the web server never ask for this kind of information.

share|improve this answer
    
Does the host header change in the case of the CNAME? Ex: www.example.tld is a CNAME for example.tld. Will the new host header be example.tld instead of the original www.example.tld? –  htg589 Mar 3 '12 at 0:43
3  
@htg589: The whole point of the host header is to report the host the client asked for, not the host it actually wound up accessing. DNS resolves the host name to an IP address, whether by way of a CNAME or not is irrelevant. –  David Schwartz Mar 3 '12 at 2: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.