Virtual hosts in Lighttpd are very simple and all of the examples are very simple. But if, like me you want to have multiple types of vhosts across multiple addresses, then this is the way to do it.
First create a listening socket on the IP and port, and then nested beneath that create your virtual hosts.
$SERVER["socket"] == "111.111.111.111:443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/ssl/secure.uplinkzero.com.pem"
ssl.ca-file = "/etc/ssl/sub.class1.server.ca.pem"
$HTTP["host"] == "secure.uplinkzero.com" {
server.name = "secure.uplinkzero.com"
server.document-root = "/data/web/secure.uplinkzero.com/public_html"
server.errorlog = "/var/log/lighttpd/secure.uplinkzero.com-error.log"
accesslog.filename = "/var/log/lighttpd/secure.uplinkzero.com-access.log"
}
}
$SERVER["socket"] == "222.222.222.222:80" {
$HTTP["host"] =~ "(^|\.)linux-101\.org$" {
server.document-root = "/data/web/linux-101.org/public_html"
server.errorlog = "/var/log/lighttpd/linux-101.org-error.log"
accesslog.filename = "/var/log/lighttpd/linux-101.org-access.log"
url.rewrite-final = (
"^/system/test/(.*)$" => "/index.php?q=system/test/$1",
"^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2",
"^/([^.?]*)$" => "/index.php?q=$1",
"^/rss.xml" => "/index.php?q=rss.xml",
"^/([^.?]*\.xml)$" => "/index.php?q=$1"
)
}
$HTTP["host"] == "www.centoshowto.org" {
server.document-root = "/data/web/centoshowto.org/public_html"
server.errorlog = "/var/log/lighttpd/www.centoshowto.org-error.log"
accesslog.filename = "/var/log/lighttpd/www.centoshowto.org-access.log"
}
}
