lighty's life

lighty developer blog

Advanced Configuration in Up Upcoming 1.4.x

i’m moo, new to lighttpd

As many of you might ask: “how do i write cond1 AND cond2”. we have the answer in 1.4

i focused on the configuration of the upcoming lighttpd1.4. i made many improvements to her.

One of the most noticeable change is nesting and chaining, as you might already known as “and” / “else”:


cond_a {
cond_b {
}
}
else cond_c {
}

cond_b will match only if cond_a match first, and cond_c will not match if cond_a match first. the order the condition checked/patched is same as other programming language, c, perl, php etc.

also, “user-defined” variable and “include” is impemented. if you used to copy/paste many of your config for each vhost, u can now put them into a sub config file, and even use the variable:


. in lighttpd.conf
$HTTP[“host”] == “t1.lighttpd.net”{
var.name=“t1”
include “myvhost.conf”
}
$HTTP[“host”] == “t2.lighttpd.net”{
var.name=“t2”
include “myvhost.conf”
}
. in myvhost.conf
server.name = var.name + “.lighttpd.net”
server.document-root = “/mydocroot/” + var.name + “/public_html/”

you can also use config values such as server.name + “/…”, and even use env.* to get environment variable

i’ve also implemented(but not commited yet) “include_shell”, which parse the output of program which convert some on the fly. for example:


include “mysub.conf”

  1. compare the above line to the following
    include_shell “/usr/bin/convmimetype /etc/mime.types”
  2. same as mime.assign = array(…)

notice the above is all at config parsing time(when loading config), so no performance lost. runtime variable isn’t implemented yet. i have no idea how it should be implemented exactly, nor do i know how to avoid hurting performance.

there are more, optimization for runtime condition checking, pcre_study speed up for regex matching, new command line options(check with -h).

FIY, before i implement these things. i myself use m4, a macro language to write the config. it’s powerful but ugly and dirty, and is just a brain dead game. i can use variable/include in m4, but not output “else” “and”. but i can now do all what i needed in lighttpd alone without m4.

check news when 1.4 is out, or check svn :)

Please note that we won't accept comments for posts older than 3 months! Also please use our bug tracker to report bugs, and our irc channel #lighttpd@libera to chat.

« Logo Contest for lighty lighttpd on cygwin »