I have an Amazon ec2 instance with a static public IP and a public domain name assigned by Amazon (ec2-my-hosts-public-ip.compute-1.amazonaws.com. Let's call it ec2.amazon.com).
I have a domain name, example.com. In my DNS, I have example.com forward to point to www.example.com.
www.example.com has an A name record pointing to my ec2 instance's public IP.
On my ec2 instance, I have two web folders: /var/www, and /var/www-public. Apache vhosts are set up to point www.example.com at /var/www-public. By default, vhosts point ec2.amazon.com at /var/www. Enjoy this little table:
www.example.com --> /var/www-public ec2.amazon.com --> /var/www
I wanted a shorter alias for my ec2.amazon.com address (remember, it's really ec2-my-hosts-public-ip.compute-1.amazonaws.com), so I set up a CNAME record to point ec2.example.com at ec2.amazon.com:
ec2.example.com CNAME ec2.amazon.com
However, I ran into a problem. Many (possible all?) DNS setups will respond to a request for ec2.example.com by simply returning the IP address of ec2.amazon.com as if it had just found an A name record, and the client won't be able to tell that an alias was involved. This is a problem because then the HTTP request that the browser sends to my server lists the domain as "ec2.example.com" rather than "ec2.amazon.com," and my server has no vhost set up for ec2.example.com, so it just defaults to the wrong page.
For reasons that are not really important, I can't alter this apache configuration. Using only DNS records, is it possible for me to remedy this? An ideal solution would be for the client (most likely a browser) to be somehow informed of this aliasing so that it could send "ec2.amazon.com" in its HTTP request header. Basically, I want it to act like a DNS forward rather than a normal CNAME. I initially thought that PTR records looked promising, since, according to Wikipedia, "Unlike a CNAME, DNS processing does NOT proceed, just the name is returned," which is exactly what I wanted (at least, the name being returned part), but I later discovered that PTR records are only associated to IP addresses for reverse-DNS.