disable logging of images in access log


SetEnvIfNoCase Request_URI "\.(gif|jpe?g|png|htc|css|js|ico)$" skiplog
CustomLog "/var/log/httpd/access.log" combined env=!skiplog


$HTTP["url"] =~ "\.(gif|jpe?g|png|htc|css|js|ico)$" {
  accesslog.filename = "/dev/null"

lighttpd redirect to external url if file not found

Below is a rewrite/redirect rule using url.rewrite-[repeat]-if-not-file similar to Apaches' "!-f" RewriteRule.

# Redirect to external url if image file not found
url.rewrite-if-not-file = ( "^\/images\/.*\.jpg$" => "/redirect$0" )
url.redirect = ( "^\/redirect\/(.*)$" => "http://other.domain.tld/$1" )

Deny access to .htaccess files in lighttpd

In lighttpd you can use mod_access to deny files starting with a certain expression, such as hidden dot files. (example: .htaccess or .svn)

# Deny access to hidden files
$HTTP["url"] =~ "/\." {
    url.access-deny = ("")

Munin stats for apache and lighttpd

Get status of apache (80) and lighttpd (81) on different ports:

This is done at the nodes.

  1. Enable apache server-status in httpd.conf :
    <Location /server-status> 
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from
  2. Enable lighttpd server-status in lighttpd.conf :
    $HTTP["remoteip"] == "" {
    status.status-url          = "/server-status"
  3. Create /etc/munin/plugin-conf.d/apache:
    env ports="80 81" 

    * Test with:

    ports="80 83" /etc/munin/plugins/apache_processes

lighttpd idle process will be a straight line as total of busy and idle process is always the same when drawn as STACK, . To change this to LINE1:

At the host, edit "/etc/munin/munin.conf" and add the below line to the corresponding host:

apache_processes.idle81.draw LINE1

Lighttpd client side optimization

  1. Edit conf file: /etc/lighttpd/lighttpd.conf
  2. Enable mod_expire and mod_compress.
  3. Expire static files set for 3 days:
    $HTTP["url"] =~ "\.(js|css|gif|jpg|png|ico|txt|swf|html|htm)$" { expire.url = ( "" => "access 3 days" ) }
  4. Compress mime types:
    compress.cache-dir         = "/var/cache/lighttpd/compress/"
    compress.filetype          = ("text/plain", "text/html", "text/css", "text/xml", "text/javascript")
  5. Cleanup the compressed cache via daily cron script:
    # lighttpd_cache_clean
    # Clean cache stored at /var/cache/lighttpd/compress
    # Place in /etc/cron.daily

    # Cache dir path

    #Deleting files older than 3 days

    # Lighttpd user and group

    # start cleaning
    /usr/sbin/tmpwatch --mtime ${HOURS} ${CROOT}

    # if directory missing just recreate it
    if [ ! -d $CROOT ]
            mkdir -p $CROOT
            chown ${LUSER}:${LGROUP} ${CROOT}

    exit 0
  6. Create the cache directory and update permissions:
    mkdir -p /var/cache/lighttpd/compress
    chown lighttpd:lighttpd /var/cache/lighttpd/compress
  7. Restart lighttpd.

Syndicate content