-   Linux - Server (
-   -   Restricting access to Apache directories (

mcc28 09-28-2012 12:37 PM

Restricting access to Apache directories

I have LAMP running on Ubuntu 12.04. Besides this I also have installed in subdirectories under /var/www/ webmin, ossec, gallery, etc.

I have a no-ip domain so my default webpage is served from

I want to be able to prevent access to or except from my LAN 192.168.0.x but have access to from anywhere.

What is the easiest (simple) and least time consuming way to do this please?


roreilly 09-28-2012 06:24 PM

You are going to need to add some security.

You have several options. You can use htpasswd ,and put a username/password prompt in front of those directories,
or you can do directory security.

Directory security would look something like this:

<Directory /var/www/webmin/>
Order, Deny, Allow
Deny from All
Allow from 192.168.0.

If you want to use username/password protection so that you can still access these directories from the outside,
then I would add htpasswd:

<Directory /var/www/webmin/>
AllowOverride AuthConfig
AuthType Digest
AuthName "something_goes_here"
AuthDigestProvider file
AuthUserFile /etc/apache2/htaccess/digest_file_name
Require valid-user
Order, Deny, Allow
Deny from All
Allow from 192.168.0.
Satisfy Any

I use the 2nd option for myself. It allows passowrd-less access from my local lan,
but when I connect from outside, it requires a username/password.

All times are GMT -5. The time now is 01:22 PM.