2

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.

htg589
  • 23
  • 3

2 Answers2

3

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.

Gregory MOUSSAT
  • 1,737
  • 2
  • 25
  • 48
  • 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 03 '12 at 00: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 03 '12 at 02:04
2

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.

Ladadadada
  • 25,847
  • 7
  • 57
  • 90