Es geht, aber etwas anders als ich es in Erinnerung hatte. Hier mal eine vollständige lighttpd.conf inklusive der richtigen Lösung (bitte Pfade und Co selbst anpassen):
Code: Select all
server.username = "lighttpd"
server.groupname = "lighttpd"
server.stat-cache-engine = "fam"
server.event-handler = "linux-sysepoll"
server.pid-file = "/var/run/lighttpd.pid"
server.errorlog = "/var/log/lighttpd/error_log"
server.document-root = "/var/www/localhost/htdocs"
server.name = "www.domain.tld"
server.max-fds = 2048
server.modules = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_auth",
"mod_setenv",
"mod_expire",
"mod_fastcgi",
"mod_cgi",
"mod_ssi",
"mod_compress",
"mod_accesslog",
)
server.indexfiles = (
"index.html",
"index.htm",
"index.php",
)
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tgz" => "application/x-tgz",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".asc" => "text/plain",
".c" => "text/plain",
".h" => "text/plain",
".cc" => "text/plain",
".cpp" => "text/plain",
".hh" => "text/plain",
".hpp" => "text/plain",
".conf" => "text/plain",
".log" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".diff" => "text/plain",
".patch" => "text/plain",
".ebuild" => "text/plain",
".eclass" => "text/plain",
".rtf" => "application/rtf",
".bmp" => "image/bmp",
".tif" => "image/tiff",
".tiff" => "image/tiff",
".ico" => "image/x-icon",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar",
".tar.gz" => "application/x-tgz",
".bz2" => "application/x-bzip",
".gz" => "application/x-gzip",
".tar" => "application/x-tar",
".zip" => "application/zip",
".jpeg" => "image/jpeg",
".jpg" => "image/jpeg",
".png" => "image/png",
".gif" => "image/gif",
".xhtml" => "text/html",
".html" => "text/html",
".htm" => "text/html",
".dtd" => "text/xml",
".xml" => "text/xml",
".css" => "text/css",
".js" => "text/javascript",
".php" => "application/x-httpd-php",
"" => "text/plain",
)
static-file.exclude-extensions = (
".pl",
".cgi",
".fcgi",
".php",
)
dir-listing.activate = "disable"
dir-listing.hide-dotfiles = "enable"
dir-listing.encoding = "utf-8"
dir-listing.exclude = (
"^\.",
"~$",
"favicon.ico",
"robots.txt",
)
url.access-deny = (
"~",
".ini",
".inc",
".cfg",
".tpl",
".bak",
".dist",
".orig",
".htaccess",
".htpasswd",
".example",
".sample",
".lang",
)
cgi.assign = (
".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
)
ssi.extension = (
".shtml",
)
compress.filetype = (
"text/javascript",
"text/plain",
"text/html",
"text/css",
)
accesslog.filename = "/var/log/lighttpd/access_log"
accesslog.format = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.use-sslv2 = "disable"
ssl.ca-file = "/etc/ssl/lighttpd/cacert.pem"
ssl.pemfile = "/etc/ssl/lighttpd/server.pem"
server.document-root = "/var/www/localhost/htdocs-secure"
accesslog.filename = "/var/log/lighttpd/ssl_access_log"
auth.backend.htpasswd.userfile = "/etc/lighttpd/auth_htpasswd.user"
auth.backend = "htpasswd"
auth.require = (
"/" => (
"method" => "basic",
"realm" => "restricted area",
"require" => "valid-user",
),
)
}
$SERVER["socket"] == ":80" {
$HTTP["host"] =~ "(^|\.)domain\.tld$" {
$HTTP["host"] != "www.domain.tld" {
url.redirect = (
"^/(.*)" => "http://www.domain.tld/",
)
}
$HTTP["host"] == "www.domain.tld" {
server.name = "www.domain.tld"
server.document-root = "/var/www/localhost/htdocs"
fastcgi.server = (
".php" => (
"localhost" => (
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "500",
"PHPRC" => "/etc/php5/cgi/",
),
"bin-copy-environment" => (
"PATH", "SHELL", "USER",
),
),
),
)
}
}
}