Oct 21, 2011
tom

Can I restrict a vhost to only a local IP?

Question

I have a subdomain I’d like to only be accessible by a local IP address. Is it possible to specify this in the vhost? I’m thinking it’s not since I haven’t found much on Google. If not, what’s the best way to do this on an apache level? I forget the version of Linux we’re using… but we have Samba running on it.

The site I’m trying to restrict is our site’s documentation.

Answer

Default Apache VirtualHost configuration has alias for /doc/ that redirects to Apache’s documentation and access is restricted only to localhost. I think that is what you are looking for. Look at the Deny and Allow lines.

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

Related posts:

  1. is there something wrong with this apache vhost?
  2. Apache2: IP rendering vhost when I don’t want it to?
  3. Can I share my vhost to my local workgroup?
  4. Apache VHost localhost not working on OSX
  5. Can’t get simple Apache VHost up and running

Leave a comment