2

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?

4

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>
3

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.

  • let me test it .. – hkguile Dec 24 '12 at 5:49
2

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.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.