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 LAMP server. It has several vhosts configured. If I navigate to:

http://xxx.xxx.xxx.xxx/  (server IP)

Apache displays one of the sites. How can I configure Apache to show nothing or perhaps a 403 Forbidden? If it could show a forbidden before checking for malformed requests that would be even better.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The first vhost that Apache picks up from your configuration is the default one picked when the name that the client sends doesn't match any configured vhost, so you'll have to make a vhost that sends 403 errors and ensure that it's picked up first in the httpd config.

share|improve this answer
    
Will this show the 403 even if it's a malformed request where a 400 would normally be served? Also what's the syntax in the vhost directive to issue the 403? –  ServerBloke Mar 30 '12 at 19:23
1  
Order Allow,Deny, Deny from all. Put it in a <Location /> block in the default (first) vhost. –  Shane Madden Mar 30 '12 at 19:51
    
Thanks, the 403 can also be done by removing the DocumentRoot in the first vhost. –  ServerBloke Apr 2 '12 at 8:30

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.