Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i have a centos + webmin + virtualmin installed. The web server is hosting multiple website.

For example: domainA.myftp.org
domainB.myftp.org
domainC.myftp.org

all domain sharing same ip address

but when i directly type the public ip address 123.123.123.123, the browser will display domainA.myftp.org

where can i set the website directory of an ip address? It this a dns or Apache virtual host or other issue? anyone knows?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

As BillThor mentioned, the first host will be the default if nothing matches. And to override that and use a host other than the first, you can enter the ip address on the apache ServerAlias line, something like this:

# Use name-based virtual hosting.
#
NameVirtualHost *


<VirtualHost *>
    DocumentRoot /var/www/
   ServerName myhost.com
   ServerAlias 10.20.30.40
   ErrorLog logs/my-error_log
   CustomLog logs/my-access_log common
<Directory /var/www/>
    AllowOverride All
    Order allow,deny
    Options -Indexes FollowSymLinks ExecCGI
    Allow from all
</Directory>
</VirtualHost>
share|improve this answer
add comment

In the absence of an explicit IP-based virtual host...

<VirtualHost ipaddress:80>
 DocumentRoot /srv/www/bare-ip/
</VirtualHost>

It'll pick the first virtual-host that matches the IP address wild-card:

<VirtualHost *:80>
  ServerName domainA.myftp.org
  stuff
</VirtualHost>

This gives you your answer, you need an IP-based virtual host declaration to give an explicit web-directory for a bare IP request.

share|improve this answer
    
let me test it .. –  hkinterview Dec 24 '12 at 5:49
add comment

This is standard behavior. Apache matches the first (default) site if no sites match. I setup a default domain to handle cases like this as well as invalid (unconfigured) domains.

To support multiple domains by IP address, you will need multiple IP addresses. This also usually the case if you want to support multiple domains over SSL. There are some workarounds for SSL.

share|improve this answer
add comment

Your Answer

 
discard

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.