0

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: 78.9.10.11. For every site a VirtualHost is defined like this:

<VirtualHost *:80>
  ServerName mydomain.com
  ServerAlias *.mydomain.com
  ....
</VirtualHost>

It works fine, but there is a configuration problem: If someone tries to access the server via its IP address (http://78.9.10.11), 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?

1
  • that behavior is By-Design and expected - if you've set global listening for the IP address
    – warren
    Nov 29, 2009 at 8:32

2 Answers 2

4
<VirtualHost 78.9.10.11>
  ....
</VirtualHost>

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

1
  • 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. Nov 29, 2009 at 14:58
1

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .