Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get Apache virtual hosting to work with an Amazon EC2 instance. My httpd.conf looks like the following

ServerName <elastic_ip>:80
Listen 80
NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot /var/www/sites/site1

Where the elastic_ip is roughly like a static IP in Amazon-land. My problem is that the site is not loading properly. For example when I type the following in the browser address bar:

EC2-public-dns     .... this works and loads the virtual host site
www.EC2-public-dns .... this doesn't load and gives "The requested URL could not be        retrieved", i.e. not any default page
elastic-ip         .... same as above
www.elastic-ip     .... same as above

I don't have anything in the /etc/hosts file, perhaps I should? Any thoughts on what I'm doing wrong?

Update: these are my setting in Godaddy now.

DNS Manager: Available 
A          @
CNAME      www
share|improve this question
CNAME www should probably be CNAME www @ see the Adding or editing CNAME records section in this document – Iain Sep 12 '11 at 19:10
up vote 4 down vote accepted

You are working with Name-Based virtual hosts. This requires that you have some method of mapping the name to the elastic IP address of your instance. You can do this using a hosts file but it would only be accessible from the instance itself. Normally you would arrange to have a DNS A or CNAME record resolve to the Elastic IP address of your instance for the names you want your server to deliver.        CNAME            A
share|improve this answer
Thanks for the response - at my domain registrar (godaddy) I have a DNS A record already pointing to the elastic ip. Regarding the information in the "highlighted box" - this should go in the hosts file - is that correct? – trican Sep 12 '11 at 12:07
www.EC2-public-dns should be a CNAME in the godaddy DNS pointing to the DNS A record for www.EC2-public-dns. – Iain Sep 12 '11 at 12:13
In the Zone file editor on Godaddy within the A record section I set the field "@" to and within the CNAME section I set the "www" field to www.public-dns I guess I need to wait a while for this to update? – trican Sep 12 '11 at 12:58
You probably need to point the www field to the @ record see here – Iain Sep 12 '11 at 13:02
Its now more than 12 hours since I updated the DNS records on godaddy, but yet I still can't reach the site via the domain name. Since I can access the site using the public dns of the EC2 instance, I'm assuming my Apache configuration is correct. So how would I go about debugging the current problem? – trican Sep 13 '11 at 9:04

Your Answer


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.