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

1 Answer

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
</VirtualHost>

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

00-localhost.conf

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