These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Direct IP access on the new forum.
Hi all,
I'm just wondering if there's a way to direct all traffic that hits the server that either doesn't have a virtual server or is simply accessed directly by IP to a particular virtual server?
Currently, it's showing a virtual server I don't particuarly want shown.
Create a new conf called sharedip.conf
In it add:
[code:1]<VirtualHost IP:80>
ServerName localhost
ServerAdmin root@localhost
DocumentRoot /var/www/sharedip
<Directory "/var/www/sharedip">
allow from all
Options +Indexes
</Directory>
</VirtualHost>[/code:1]
And repeat for all IP's you have. Then create the index.(s)html/php you want displayed when a IP is used.
Don't forget you need to add the NameVirtualHost for each IP as well.
Scott's advice will work, if you want specific content different from all of your existing Virtual Servers in Virtualmin--e.g. if you want an index page listing all of your sites or something that links folks off to the correct name-based site if folks somehow end up accessing your site by IP.
Or, if you just want some specific site from among your existing Virtualmin servers to show up, you just need its VirtualHost section to appear first in the Apache configuration...Apache has two modes, "single-site" and "named-based virtual hosting", and the name-based mode no longer has any concept of a "default" site...it just serves whatever the first VirtualHost that matches all of the qualifiers is. So, 192.168.1.1:80 will grab the first VirtualHost that lives on that IP and port--regardless of your wishes that it grab something else.
You've neglected to tell us your OS, so you're own your own about finding the right configuration file(s). (But I'll give the hint that on Debian/Ubuntu, you don't actually reorder the sections since they're in their own files...you just rename one of them to 00hostname.conf to force it to be the first to be pulled in during Apache startup.)
And of course, there is documentation about this subject here:
http://www.virtualmin.com/documentation/id,troubleshooting_common_proble...
--
Check out the forum guidelines!