123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- # webserver config https://lighttpd.net
- var.baseurl = "/"
- auth.backend = "htdigest"
- auth.backend.htdigest.userfile = "/etc/lighttpd/internet-radio-recorder.user.htdigest"
- # $ sudo htdigest -c /etc/lighttpd/internet-radio-recorder.user.htdigest 'Radio Pi' <uid>
- $HTTP["request-method"] == "HEAD" {
- # allowed
- } else $HTTP["query-string"] == "atom" {
- # allowed
- } else $HTTP["query-string"] == "rss" {
- # allowed
- } else $HTTP["url"] =~ "\.mp3$" {
- # for legal reasons mp3 access must be restricted, http://de.wikipedia.org/wiki/Privatkopie#Deutschland
- auth.require = ( baseurl + "enclosures" => (
- # see /usr/share/doc/lighttpd/authentication.txt.gz
- "method" => "digest",
- "realm" => "Radio Pi",
- "require" => "valid-user",
- ), )
- }
- # http://www.golem.de/news/content-security-policy-schutz-vor-cross-site-scripting-1306-99795.html
- setenv.add-response-header = (
- # http://www.w3.org/TR/CSP/#example-policies
- # 'unsafe-inline' for the lighttpd-generated directory listings
- "Content-Security-Policy" => "default-src 'none'; style-src 'self' 'unsafe-inline'; script-src 'self'; connect-src 'self'; font-src 'self'; img-src *;",
- )
- # enable directory browsing:
- dir-listing.activate = "enable"
- dir-listing.encoding = "utf-8"
- dir-listing.show-readme = "enable"
- url.redirect = (
- "^" + baseurl + "(stations/[^/]+)/now(\?.*)?$" => "../../app/onair.cgi/$1$2",
- "^" + baseurl + "podcasts/[^/]+/([^/]+/[0-9]{4}/[0-9]{2}/[0-9]{2}/[0-9]{4})$" => "../../../../../../stations/$1.xml",
- "^" + baseurl + "podcasts/([^/]+)\.(atom|rss)$" => "$1/broadcasts.$2",
- # legacy <2022:
- "^" + baseurl + "(podcasts/radio)_(mitschnitt/broadcasts.rss)$" => "../../$1$2",
- "^" + baseurl + "stations/[^/]+/[0-9]{4}/[0-9]{2}/[0-9]{2}/([0-9]{4})( .+)?$" => "$1.xml",
- )
- $HTTP["url"] =~ "\.xml\.gz$" {
- # serve pre-compressed content to be unpacked by client
- setenv.add-response-header = ( "Content-Encoding" => "gzip")
- mimetype.assign = (".xml.gz" => "text/xml; charset=utf-8" )
- }
- cgi.assign = (
- "app/monitor.cgi" => "/bin/dash",
- "app/onair.cgi" => "/bin/dash",
- "enclosures/app/ad_hoc.cgi" => "/bin/dash",
- "i.cgi" => "/bin/dash",
- )
- # proper mimetypes + encodings:
- mimetype.assign = (
- ".atom" => "text/xml; charset=utf-8",
- ".aac" => "audio/aac",
- ".cfg" => "text/plain; charset=utf-8",
- ".css" => "text/css; charset=utf-8",
- ".html" => "text/html; charset=utf-8",
- ".ico" => "image/vnd.microsoft.icon",
- ".ics" => "text/calendar; charset=utf-8",
- ".json" => "application/json; charset=utf-8",
- ".js" => "text/javascript; charset=utf-8",
- ".log" => "text/plain; charset=utf-8",
- ".m4a" => "audio/mpeg",
- ".mp3" => "audio/mpeg",
- ".pending" => "text/plain; charset=utf-8",
- ".png" => "image/png",
- ".podcasts" => "text/plain; charset=utf-8",
- ".rdf" => "application/rdf+xml; charset=utf-8",
- ".reserved" => "text/plain; charset=utf-8",
- ".ripping" => "audio/mpeg",
- ".rnc" => "text/plain; charset=utf-8",
- ".rng" => "text/xml; charset=utf-8",
- ".rss" => "application/rss+xml; charset=utf-8",
- ".scheduled" => "text/plain; charset=utf-8",
- ".sh" => "text/plain; charset=utf-8",
- ".svg" => "image/svg+xml",
- ".ttl" => "text/turtle; charset=utf-8",
- ".txt" => "text/plain; charset=utf-8",
- ".xml" => "text/xml; charset=utf-8",
- ".xslt" => "text/xml; charset=utf-8",
- )
- # bandwidth saving:
- deflate.mimetypes = (
- "application/json",
- "application/rdf+xml",
- "application/rss+xml",
- "application/xslt+xml",
- "image/svg+xml",
- "text/calendar",
- "text/css",
- "text/html",
- "text/javascript",
- "text/plain",
- "text/turtle",
- # "text/xml",
- )
- # /usr/share/doc/lighttpd-doc/expire.txt
- $HTTP["url"] !~ "/onair\.cgi$" {
- # expire all but onair.* - has to set header itself
- expire.url = (
- "/app/" => "access 0 years",
- "" => "access 2 minutes",
- )
- }
- $HTTP["url"] =~ "\.(cfg|js|css|xslt|png|ico|mp3|ttl)$" {
- expire.url = ( "" => "access 1 days" )
- }
- $HTTP["url"] =~ "\.(ics|rdf)$" {
- expire.url = ( "" => "access 55 minutes" )
- }
- $HTTP["url"] =~ "\.(rss)$" {
- expire.url = ( "" => "access 2 minutes" )
- }
- $HTTP["url"] =~ "(modified\.ttl)$" {
- expire.url = ( "" => "modification 55 minutes" )
- }
- $HTTP["url"] =~ "modified-.*\.ttl$" {
- expire.url = ( "" => "modification 10 years" )
- }
- etag.use-inode = "enable"
- etag.use-mtime = "enable"
- etag.use-size = "enable"
- static-file.etags = "enable"
|