Skip to content

Commit 63cc9ef

Browse files
committed
Modernize lighttpd.conf
1 parent d59c8db commit 63cc9ef

File tree

1 file changed

+74
-101
lines changed

1 file changed

+74
-101
lines changed

lighttpd.conf

Lines changed: 74 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Lighttpd Server Configs | MIT License
22
# https://github.com/h5bp/server-configs-lighttpd
33

4-
# http://redmine.lighttpd.net/projects/lighttpd/wiki
4+
# https://wiki.lighttpd.net/
55

66
# Run as an unprivileged user
77
server.username = "www"
@@ -14,33 +14,19 @@ server.pid-file = "/var/run/lighttpd/lighttpd.pid"
1414
# mod_simple_vhost module.
1515
server.document-root = "/var/www/sites/go/here/"
1616

17-
# Avoid revealing the server name and version number
18-
server.tag = ""
19-
20-
# Disable directory listing
21-
server.dir-listing = "disable"
17+
# Avoid revealing the server version number
18+
server.tag = "lighttpd"
2219

2320
# Modules to load
24-
# at least mod_access and mod_accesslog should be loaded
25-
# mod_expire should go above mod_compress (and mod_fcgi if you use it)
26-
# otherwise expire headers will not be applied to compressed documents.
2721
server.modules = (
2822
"mod_access",
29-
"mod_accesslog",
30-
"mod_redirect",
23+
"mod_indexfile",
24+
"mod_staticfile",
3125
"mod_expire",
32-
"mod_compress",
33-
"mod_setenv"
26+
"mod_deflate",
27+
"mod_accesslog",
3428
)
3529

36-
# Sent Response Headers
37-
# opt-in to the future - remove meta tag from page
38-
setenv.add-response-header = ( "X-UA-Compatible" => "IE=edge" )
39-
40-
# File uploads
41-
# Make sure this folder exists and is writable to server.username
42-
server.upload-dirs = ( "/tmp/lighttpd/uploads" )
43-
4430
# Where to send error-messages to
4531
server.errorlog = "/var/log/lighttpd/error.log"
4632

@@ -49,8 +35,9 @@ accesslog.filename = "/var/log/lighttpd/access.log"
4935

5036
# Compression
5137
# Make sure this folder exists and is writable to server.username
52-
compress.cache-dir = "/tmp/lighttpd/compress/"
53-
compress.filetype = (
38+
deflate.cache-dir = "/tmp/lighttpd/compress/"
39+
deflate.mimetypes = (
40+
"text/",
5441
"application/atom+xml",
5542
"application/javascript",
5643
"application/json",
@@ -72,17 +59,6 @@ compress.filetype = (
7259
"image/svg+xml",
7360
"image/vnd.microsoft.icon",
7461
"image/x-icon",
75-
"text/cache-manifest",
76-
"text/css",
77-
"text/html",
78-
"text/javascript",
79-
"text/plain",
80-
"text/vcard",
81-
"text/vnd.rim.location.xloc",
82-
"text/vtt",
83-
"text/x-component",
84-
"text/x-cross-domain-policy",
85-
"text/xml",
8662
)
8763

8864
# Files to check for if .../ is requested
@@ -91,9 +67,6 @@ index-file.names = (
9167
"index.htm",
9268
)
9369

94-
# Set the event-handler (read the performance section in the manual)
95-
# server.event-handler = "freebsd-kqueue" # needed on OS X
96-
9770

9871
# Serve resources with the proper media types (f.k.a. MIME types).
9972
# https://www.iana.org/assignments/media-types/media-types.xhtml
@@ -116,9 +89,9 @@ mimetype.assign = (
11689
# JavaScript
11790

11891
# Normalize to standard type.
119-
# https://tools.ietf.org/html/rfc4329#section-7.2
92+
# https://www.rfc-editor.org/rfc/rfc9239
12093

121-
".js" => "application/javascript",
94+
".js" => "text/javascript",
12295

12396

12497
# Manifest files
@@ -239,75 +212,75 @@ mimetype.assign = (
239212
# Block access to backup and source files.
240213
url.access-deny = ( "~", ".inc" )
241214

242-
$HTTP["url"] =~ "\.pdf$" {
243-
server.range-requests = "disable"
244-
}
245-
246215
# Extensions that should not be handle via static-file transfer.
247216
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
248217
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
249218

250219
# Bind to all IPs, or change to a specific IP.
251-
server.bind = "0.0.0.0"
220+
#server.bind = "0.0.0.0"
221+
252222

253223
# Expires headers (for better cache control)
254224
# The following expires headers are set pretty far in the future. If you don't
255225
# control versioning with filename-based cache busting, consider lowering the
256226
# cache time for resources like CSS and JS to something like 1 week.
257-
258-
# CSS
259-
$HTTP["url"] =~ ".css" {
260-
expire.url = ( "" => "access plus 1 years" )
261-
}
262-
263-
# Data interchange
264-
$HTTP["url"] =~ ".(json|xml)" {
265-
expire.url = ( "" => "access plus 0 seconds" )
266-
}
267-
268-
# Favicon
269-
$HTTP["url"] =~ ".ico" {
270-
expire.url = ( "" => "access plus 7 days" )
271-
}
272-
273-
# HTML components (HTCs)
274-
$HTTP["url"] =~ ".htc" {
275-
expire.url = ( "" => "access plus 1 months" )
276-
}
277-
278-
# HTML
279-
$HTTP["url"] =~ ".html" {
280-
expire.url = ( "" => "access plus 0 seconds" )
281-
}
282-
283-
# JavaScript
284-
$HTTP["url"] =~ ".js" {
285-
expire.url = ( "" => "access plus 1 years" )
286-
}
287-
288-
# Manifest files
289-
$HTTP["url"] =~ ".(appcache|manifest|webapp)" {
290-
expire.url = ( "" => "access plus 0 seconds" )
291-
}
292-
293-
$HTTP["url"] =~ ".webmanifest" {
294-
expire.url = ( "" => "access plus 1 week" )
295-
}
296-
297-
# Media
298-
$HTTP["url"] =~ ".(gif|jpg|jpeg|png|m4a|f4a|f4b|oga|ogg|webm)" {
299-
expire.url = ( "" => "access plus 1 months" )
300-
}
301-
302-
# Web feeds
303-
$HTTP["url"] =~ ".(atom|rss)" {
304-
expire.url = ( "" => "access plus 1 hours" )
305-
}
306-
307-
# Web fonts
308-
$HTTP["url"] =~ ".(eot|otf|svg|svgz|ttf|ttc|woff)" {
309-
expire.url = ( "" => "access plus 1 months" )
310-
}
311-
312-
# Default
313-
expire.url = ( "" => "access plus 1 months" )
227+
expire.mimetypes = (
228+
## HTML
229+
"text/html" => "access plus 0 seconds",
230+
231+
## Data interchange
232+
"application/json" => "access plus 0 seconds",
233+
"application/ld+json" => "access plus 0 seconds",
234+
"application/geo+json" => "access plus 0 seconds",
235+
"application/schema+json" => "access plus 0 seconds",
236+
"application/xml" => "access plus 0 seconds",
237+
"text/calendar" => "access plus 0 seconds",
238+
"text/markdown" => "access plus 0 seconds",
239+
"text/xml" => "access plus 0 seconds",
240+
241+
## Manifest files (.webapp .appcache .webmanifest)
242+
"application/x-web-app-manifest+json"
243+
=> "access plus 0 seconds",
244+
"text/cache-manifest" => "access plus 0 seconds",
245+
"application/manifest+json" # .webmanifest
246+
=> "access plus 1 week",
247+
248+
## Web feeds
249+
"application/atom+xml" => "access plus 1 hour",
250+
"application/rdf+xml" => "access plus 1 hour",
251+
"application/rss+xml" => "access plus 1 hour",
252+
253+
## Favicon (.ico)
254+
"image/x-icon" => "access plus 1 week",
255+
256+
## Javascript
257+
#"text/javascript" => "access plus 1 month",
258+
259+
## CSS (.css)
260+
#"text/css" => "access plus 1 month",
261+
262+
## Media
263+
#"audio/" => "access plus 1 month",
264+
#"image/" => "access plus 1 month",
265+
#"video/" => "access plus 1 month",
266+
267+
## WebAssembly
268+
#"application/wasm" => "access plus 1 month",
269+
270+
## HTML components (HTCs)
271+
#"text/x-component" => "access plus 1 month",
272+
273+
## Web fonts
274+
#"font/" => "access plus 1 month",
275+
#"application/x-font-ttf" => "access plus 1 month",
276+
#"application/x-font-woff" => "access plus 1 month",
277+
#"application/font-woff" => "access plus 1 month",
278+
#"application/vnd.ms-fontobject"
279+
# => "access plus 1 month",
280+
281+
## binary or unspecified
282+
"application/octet-stream" => "access plus 0 seconds",
283+
284+
## Default
285+
"" => "access plus 1 month"
286+
)

0 commit comments

Comments
 (0)