HOWTO: Setup restricted directories on lighttpd

Restricted directories in lightttpd will be setup using mod_auth package and htpasswd.

if you don’t already have htpasswd installed on your box do a apt-get

* apt-get install apache2-utils

Create password file

* htpasswd -c -m /etc/lighttpd/htpasswd

(Default encryption scheme is MD5)

Modify Lighttpd Config file

* vi /etc/lighttpd/lighttpd.conf

Add mod_auth on server.modules

server.modules              = (

Add following authorization module configurations
auth.backend = “htpasswd”
auth.backend.htpasswd.userfile = “/etc/lighttpd/htpasswd”
auth.require = ( “/directory-to-be-protected/” => (
                        “method” => “basic”,
                        “realm” => “Access restricted to authorized users only”,
                        “require” => “valid-user”
Reload lighttpd configuration
/etc/init.d/lighttpd reload

Leave a Reply

Your email address will not be published. Required fields are marked *