Skip to main content

Qmailadmin with Lighttpd

Posted in

Configure Qmailadmin to work with the Lighttpd webserver.

Lighttpd Configuration
With a basic Lighttpd server configured as per this site's instructions and running under daemontools, create a file /service/lighttpd/root/qmailadmin.inc to hold the server options for Qmailadmin:

alias.url = (
"/cgi-bin/qmailadmin" => "/var/websites/mail/cgi-bin/qmailadmin",
"/images/qmailadmin" => "/var/websites/mail/htdocs/images/qmailadmin"
)

$HTTP["url"] =~ "^/cgi-bin/qmailadmin" {
cgi.assign = ( "/var/websites/mail/cgi-bin/qmailadmin" => "" )
}

Edit your lighttpd.conf and add an include for your qmailadmin.inc file:
include "qmailadmin.inc"

Also, make sure CGIs are enabled in your lighttpd.conf with something similar to:
server.modules = (
"mod_cgi",
)

Securing Qmailadmin
If you are going to have Qmailadmin accessible from the public internet, you should encrypt the connection as user IDs and passwords are used.

Assuming you've already created an SSL certificate and configured Lighttpd according to the Lighttpd SSL instructions:
Redirect all qmailadmin requests, that don't come from the 192.168.0.0/24 network, to SSL:

alias.url = (
"/cgi-bin/qmailadmin" => "/var/websites/mail/cgi-bin/qmailadmin",
"/images/qmailadmin" => "/var/websites/mail/htdocs/images/qmailadmin"
)

$HTTP["url"] =~ "^/cgi-bin/qmailadmin" {
cgi.assign = ( "/var/websites/mail/cgi-bin/qmailadmin" => "" )
$SERVER["socket"] == ":80" {
  $HTTP["remoteip"] != "192.168.0.0/24" {
   url.redirect = ( "^/(.*)" => "https://%1/$1" )
  }
}
}

Resources
http://gryniewicz.com/blogs/dang/2007/05/16/qmailadmin-on-lighttpd/
http://forum.lighttpd.net/topic/1053