Weblog entry #10 for blackm

add security to http auth using mod_access
Posted by blackm on Thu 24 Nov 2005 at 22:46
Tags: none.
Marco asked if it's possible to setup apache to restrict host access and use http auth. I never had such a setup, so I gave it a try.

First I created a directory that uses http auth
cd /var/www
mkdir test
cd test
htpasswd -c htp blackm
Note: always put your password files outside your webroot!

The directory need some options to be turned of:
< Directory /var/www/test >
    AllowOverride AuthConfig Limit
< /Directory >
Put this in your apache configuration and reload it. AuthConfig make http auth working in .htaccess and Limit is for the mod_access directive

Now go back to /var/www/test and create the file .htaccess
Order Allow,Deny
Allow from [your hostname or ip] [an other one]

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /var/www/test/htp
Require valid-user
It is important that the mod_access directive are before the http auth ones. By doing this way, only hosts (your hosts) are allowed to enter username and password. This should prevent your accounts from being cracked using brut force attacks.

 

Comments on this Entry

Posted by hardik (61.95.xx.xx) on Fri 25 Nov 2005 at 11:42
[ Send Message ]
I think it's better to use htdigest over htpasswd. More security over network.You can also use mod_auth_pam module. It's good to maintain single password database. Check http://pam.sourceforge.net/mod_auth_pam/



Cheers,
Hardik Dalwadi.

[ Parent | Reply to this comment ]

Posted by blackm (212.202.xx.xx) on Fri 25 Nov 2005 at 14:42
[ Send Message | View Weblogs ]
Hi Hardik,

yes, mod_auth_pam can also be used and it is better to administrate. Some time ago I also used mod_auth_mysql to auth against a mysql database. The combination of mod_auth_pam and the pam module pam_mysql would also be possible (I used this for smtp auth in postfix / sasl).

You can do a lot things with pam, I maybe write an article on the thing's I've done so far (or at least a blog storry).

bye, Martin

--
browse ManPages online!

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search