Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have a domain name called I have an elastic IP for my AWS EC2 instance called my.ela.stic.ip. The htdocs root of my linux based EC2 instance is at /var/www/html/.

I have set up the /etc/httpd/conf.d/vhost.conf file to direct the domain to /var/www/html/my_dumb_app/ and that's working Fine! The vhost.conf file looks like this:

NameVirtualHost *
<VirtualHost *> 
   DocumentRoot /var/www/html/my_dumb_app
<VirtualHost *> 
    DocumentRoot /var/www/html/my_blog_directory

Now, I want & to keep landing on to /var/www/html/my_dumb_app/ & /var/www/html/my_blog_directory respectively; and i also want everything else via my.ela.stic.ip address to simply go to /var/www/html like normal. So that going to and going to my.ela.stic.ip/my_dumb_app would end up landing at the same location.

It just so happens that since my vhost.conf file has <VirtualHost> tags for &, trying to reach other directories of the server through the elastic_ip causes a 404-NotFound error.


share|improve this question
up vote 1 down vote accepted

As per, you can create a VirtualHost entry for the IP address.

So you'll have something like

<VirtualHost my.elas.stic.ip>
   ServerName my.elas.stic.ip
   DocumentRoot /var/www/html

Also be aware that the first vhost declaration is the default - this probably won't affect you, but anyone accessing your instance via the instance external IP, or the EC2 instance domain name will get whatever comes first.

Edit: There are several ways to access your EC2 instance. First off, every instance has both public and private IP addresses, as well as public and private DNS entries. Accessing the instance via one of these (i.e. will not match up with any of the host names, so will pick the default. When you restart in instance, and before you re-assign the elastic IP address, the same will happen for the external IP address.

share|improve this answer
thanks @chris. this worked for me. However, could you please clarify the implications of the first vhost declaration being the default part? I didn't quite get that. – syedrakib Dec 24 '12 at 16:12

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.