3

I just got a new cloud server and while setting it up, I can access the web root by pointing my browser to the IP address of my server, but the domain names are still propagating so when I go to them, they do not resolve.

When I do point my browser to the IP address of my server, it is actually resolving to the first VirtualHost that I set up which should not be the root folder. This VirtualHost should show up when I go to ipaddress/path, not just ipaddress.

Server setup:
Host: Rackspace Cloud Server
OS: CentOS 6
VirtualHosts:

<VirtualHost *:80>
    ServerAdmin www.wphax.com@gmail.com
    ServerName www.wphax.com
    ServerAlias wphax.com *.wphax.com
    DocumentRoot /var/www/wphaxcom
    ErrorLog /var/www/wphaxcom/error.log
    CustomLog /var/www/wphaxcom/access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin www.wphax.com@gmail.com
    ServerName www.dnadvanced.com
    ServerAlias dnadvanced.com *.dnadvanced.com
    DocumentRoot /var/www/dnadvancedcom
    ErrorLog /var/www/dnadvancedcom/error.log
    CustomLog /var/www/dnadvancedcom/access.log combined
</VirtualHost>

Any ideas what could cause this, and how I could set it up so the root directory is not accessible by entering the IP address, but the domain names will resolve correctly to their specified folders? Thanks.

Jared
  • 217
  • 3
  • 8

1 Answers1

3

From the Name-based Virtual Host Support article in the Apache server documentation:

IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. [...]

Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. [...]

By directly specifying an IP address, you are essentially selecting the first virtual host listed in your configuration file. Since you never specified an IP address in the configuration file, that host is listening on all IPs. How Apache determines what website to serve is dictated by the information received in the HTTP headers from the client's request.

Unless you can access both virtual hosts via independent IP addresses - or by different port numbers (i.e. set the second one to port 81) - you will have to wait for your domain name changes to propagate.


If you really need to test the server now, you can attempt to manually modify the HTTP headers after each request (using something like the Tamper Data addon for Firefox) so that Apache will serve the proper page to your browser.

Breakthrough
  • 34,847