This is the first time I actually try to setup a server myself.

Everything is working good so far. I have added a new virtual server and changed my domain´s A records and it is now working as expected.

However: I would like to "block" access to the default www dir (in my case var/www). Right now when I enter the server IP instead of the domain, I get to the default www dir - I would like to disable that.

I dont want to setup a redirect, but simply forbid users, search engines etc. to view anything when they go to http://myip/

Currently I am doing the trick with adding an empty index.html, but I would like to actually block all requests and only allow access to my domains (they are in a subdir like "var/www/sites/domain.com/www")

I hope you get what I mean - my english sucks :/

p.s. since I installed webmin and I access it through http://myIp:webminPort - I think I actually only want to block port 80, but not sure about that...


You need to keep port 80 open as all your content for the domain.com/www vhost travels through 80 as well.

There is a default vhost setup by apache, you just need to comment it out in your httpd.conf.

To edit the config in webmin:

 Webmin -> Servers -> Apache Website -> Global Configuration

Give it a slow read through and you'll find the default vhost code block, just comment it out. This is worth it as you may want to tune settings later anyways.

Andre(OP) determined the default vhost definition was in /sites-enabled/default-000

Here is the section you are looking for:

### Section 2: 'Main' server configuration
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.

Comment out these Directives within Section 2 using a hash:

#<Directory />
#---comment out all contents of this directory block---
#<Directory /var/www/html>
#---comment out all contents of this directory block---
  • Hi, Thanks for the quick answer. Unfortunately I wasn't able to find anything regarding the default vserver, but I did the following: I opened the config file in apache2/sites-enabled and added <Directory /var/www/> Options Indexes FollowSymLinks MultiViews Order allow,deny Deny from all AllowOverride None </Directory> - this works good now as I get a 403 error when accessing my ip via port 80, but can still access via webmin port. Just wondering: was that a bad idea or its fine? – Andrej Oct 23 '11 at 14:16
  • 404 Would be better. 403 indicates "forbidden". You are close you just need to comment out a couple more things to get the server to stop responding on that IP on 80. Is the file you edited the "default site" in sites-enabled/? If there is no webmin configuration in there you can safely remove it from sites-enabled/ – iainlbc Oct 23 '11 at 14:21
  • Thanks again for the tip, but it seems my config file doesnt include this parts. – Andrej Oct 23 '11 at 14:21
  • Ah, that must be a webmin thing. You are on the right track. Its likely all in the default-site vhost – iainlbc Oct 23 '11 at 14:22
  • yes it is named 000-default in sites-enabled/ and there is no webmin config, but some config regarding port 443 (ssl i guess). I am gonna save it, delete it and restore it in case something breaks – Andrej Oct 23 '11 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.