Search code examples
.htaccesslighttpdaccess-control

Allow directory access for certain IP's at Lighttpd


I need to rewrite this rules (from apache's .htaccess):

<files "*.*">
Allow from 84.47.125.0/19 66.211.160.0/19 216.113.160.0/19
Deny from All
</files>

To lighttpd ones, to allow the access to my /pswd directory only for those IP's:

84.47.125.0/19, 66.211.160.0/19, 216.113.160.0/19

How can I do that in lighttpd?


Solution

  • I've never used lighttpd but I've found this on Google: http://www.cyberciti.biz/tips/lighttpd-restrict-or-deny-access-by-ip-address.html

    It has an example for blocking access for 2 IPs and for blocking a single IP. It should be easily adaptable for you by doing this:

    # vi /etc/lighttpd/lighttpd.conf
    

    and then:

    $HTTP["remoteip"] !~ "84.47.125.0/19|66.211.160.0/19|216.113.160.0/19" {
        $HTTP["url"] =~ "^/pswd/" {
          url.access-deny = ( "" )
        }
     }