1

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
  ServerName www.site1.com
</VirtualHost>

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          @    el.as.tic.ip
CNAME      www  site1.com
CNAME      ec2-XX-XX-XX-XX.eu-west-1.compute.amazonaws.com  @
1

1 Answer 1

4

You are working with Name-Based virtual hosts. This requires that you have some method of mapping the www.site1.com 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.

www.site1.com.        CNAME  site1.com.
site1.com.            A      el.as.tic.ip
6
  • 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, 2011 at 12:07
  • 1
    www.EC2-public-dns should be a CNAME in the godaddy DNS pointing to the DNS A record for www.EC2-public-dns.
    – user9517
    Sep 12, 2011 at 12:13
  • In the Zone file editor on Godaddy within the A record section I set the field "@" to el.as.tic.ip 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, 2011 at 12:58
  • 1
    You probably need to point the www field to the @ record see here
    – user9517
    Sep 12, 2011 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, 2011 at 9:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .