View Single Post
  #6  
Old 15th August 2012, 19:50
tahunasky tahunasky is offline
Member
 
Join Date: Jul 2012
Location: Buenos Aires
Posts: 84
Thanks: 1
Thanked 8 Times in 8 Posts
Default

I think I understand what you are getting at: if you just type in the IP address of the server its points to the DocumentRoot of a clients domain and not the default web DocumentRoot directory of example.com. I had the same problem, it would point to the first domain in my DNS list. The way i fixed this was to create a new default virtual host record.

You need to relise that HOSTNAME and DOMAIN NAME are 2 different things. Even though hostname can be/is a fully qualified domain name, unless you setup a site for it there will not be one. You need to go to SITES/WEBSITES/ADD NEW SITE and create new site for example.com . So if someone puts in your servers IP address it will default to the first domain record (for me it was the first domain is DNS list) that is loaded (in apache anyways)

I use Apache, so not sure about nginx (but someone should be able to tell you want to do for nginx), but what i did for apache was:

create a new default /etc/httpd/conf/sites-available/_default.vhost file, then added the following code at the top:

Code:
<VirtualHost _default_:80>
    ServerName example.com
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/example.com/web
</VirtualHost>
OR

Code:
<VirtualHost 123.456.678.9:80>
    ServerName example.com
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/example.com/web
</VirtualHost>
You can change the DocumentRoot to point to wherever you want.

Then i created a symbolic link to the file /etc/httpd/conf/sites-enabled/000-default.vhost

Code:
ln -s /etc/httpd/conf/sites-available/_default.vhost /etc/httpd/conf/sites-enabled/000-default.vhost
This will catch all http requests to the IP address.

Last edited by tahunasky; 16th August 2012 at 01:49.
Reply With Quote