Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have an apache server running several vhosts. all of my vhosts are working great, but i came across a security hole that i need to plug.

if i go a dns entry, i get the appropriate vhost, if i go to the IP address of the server, i get the first web site that happened to be deployed. how do i lock that down so if you go to the IP address you get an error or something?

thank you.

share|improve this question
This may not be nice, but why do you call this a security hole? – Oliver May 3 '12 at 13:11
the simplest reason is if you hit it by IP address, the server does something that it isn't supposed to do. This type of issue i call a security hole. I don't know if its industry standard terminology, but its how i approach the issue. – scphantm May 7 '12 at 15:02
up vote 6 down vote accepted

just create a blank vhost and make sure it is the first vhost added to apache.. being the top of the file of the first file in alphabetic order.

What I do is this

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/localhost

    ErrorLog logs/localhost-error_log
    CustomLog logs/localhost-access_log combined

So put that at the top of your list or I have all my vhosts broken out into an include directory so my filename is


In /var/www/localhost you can have like a empty index.html or whatever you want and all requests to the IP or hosts that are directed towards you but aren't listed in a vhost will go there.

share|improve this answer
You could even use mod_redirect to have that vhost redirect to your company site on another server entirely, rather than serving an error. – pjmorse May 3 '12 at 13:23

Your Answer


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.