≡ Menu

path names

Lighttpd restrict or deny access by IP address

Lighttpd logo

So how do you restrict or deny access by IP address using Lighttpd web server?

Lighttpd has mod_access module. The access module is used to deny access to files with given trailing path names. You need to combine this with remoteip conditional configuration. Syntax is as follows:

$HTTP["remoteip"] == "IP" : Match on the remote IP
$HTTP["remoteip"] !~ "IP1|IP2" : Do not match on the remote IP (perl style regular expression not match)
$HTTP["remoteip"] =~ "IP1|IP2" : Match on the remote IP (perl style regular expression match)

Task: Match on the remote IP

For example block access to http://theos.in/stats/ url if IP address is NOT 192.168.1.5 and 192.168.1.10 (restrict access to these 2 IPs only):

Open /etc/lighttpd/lighttpd.conf file
# vi /etc/lighttpd/lighttpd.conf
Append following configuration directive:

$HTTP["remoteip"] !~ "200.19.1.5|210.45.2.7" {
    $HTTP["url"] =~ "^/stats/" {
      url.access-deny = ( "" )
    }
 }

Save and restart lighttpd:
# /etc/init.d/lighttpd restart

Task: Block single remote IP

Do not allow IP address 202.54.1.1 to access our site:

$HTTP["remoteip"] == "202.54.1.1" {
       url.access-deny = ( "" )
  }

Do not allow IP address 202.54.1.1,202.54.2.5 to access our site:
Do not allow IP address 202.54.1.1 to access our site:

$HTTP["remoteip"] =~ "202.54.1.1|202.54.2.5" {
       url.access-deny = ( "" )
  }

See also

=> Lighttpd deny access to certain files

Wordpress Logo

Since I use wordpress as CMS for 2-3 different websites, upgrading wordpress is an essential task for me. Upgrading wordpress from shell prompt is the easiest thing.

Howto update wordpress

Please note that if you are not comfortable with UNIX shell prompt (IF YOU ARE new to UNIX/Linux), please follow traditional way of upgrading wordpress and DO NOT use following instructions ;)

Step # 1: Backup existing database and wordpress directory

Type the following commands at shell prompt:

$ mkdir /backup/wp/28nov2006
$ mysqldump -u user -p WP-DATABASENAME > /backup/wp/28nov2006/blog.db.sql
$ tar -zcvf /backup/wp/28nov2006.tar.gz /var/www/html/blog

Step # 2: Download latest wordpress CMS

$ cd /tmp
$ wget http://wordpress.org/latest.zip
$ unzip latest.zip

Step # 3: Overwrite all new files

$ cd /var/www/html/blog
$ cp -avr /tmp/wordpress/* .
$ rm -rf /tmp/wordpress /tmp/latest.zip

Open a browser and run update script such as http://yourblog.com/wp-admin/upgrade.php

And you are done. Thanks to UNIX shell access. It just took less than 1 minute!!! Replace path names and database name with actual values.

In case, if something goes wrong, you can always restore old database and files from /backup/wp/28nov2006 directory.

PS: I wrote this because some one recently asked me how to upgrade wordpess from command line.