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 to admin a web server with Apache 2 to deliver some different websites - every site has its own domain. The server has a single IP address, say: For every site a VirtualHost is defined like this:

<VirtualHost *:80>
  ServerAlias *

It works fine, but there is a configuration problem: If someone tries to access the server via its IP address (, the first VirtualHost is delivered - which I don't want. Instead, the access should be blocked or a special website should be served (to render some kind of error message). The server should only deliver sites by domain names.

How can I define a VirtualHost which is used for IP based access?

share|improve this question

migrated from Nov 29 '09 at 13:12

This question came from our site for professional and enthusiast programmers.

that behavior is By-Design and expected - if you've set global listening for the IP address – warren Nov 29 '09 at 8:32
up vote 3 down vote accepted

Server up your custom error page (or whatever) inside that block.

share|improve this answer
Thanks, I have tried this before without success - but then I have recognized that my VirtualHost definition was not enabled... Argh! After doing an "a2ensite default" all works fine now. – Georg Ledermann Nov 29 '09 at 14:58

Make sure the first VirtualHost that appears in your config file is like this

<VirtualHost *:80>
  ServerName not.configured
  DocumentRoot /var/www/notconfigured

And then create an index.html in /var/www/notconfigured with the message you want

share|improve this answer

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.