lighty's life

lighty developer blog

Spice Up for Error Page

lighttpd isn’t beautiful when it shows the user that a file is not available.

When I wrote it I want to make sure to don’t show any information that might be used for XSS attacks like displaying the URL unencoded, show local paths, … something like that. I used the simplest approach: Just show the status.

This is not pretty, but works. But I assume you want something more sexy.

There are two ways to handle the output of a error page.

  • server.errorfile-prefix
  • server.error-handler-404

The first is used to use a local, static file as the payload for the status pages.

  • create a directory
  • put into that directory a file name 404.html
  • set server.errorfile-prefix do the directory name including the trailing slash

The file has to be a static HTML file (no PHP, …). thinking If you already have a set of nice looking error-pages perhaps you can provide them for other users. The lighty-errorpage-theme-packages.

The other way is to use the error-handler which only works for the file-not-found case. The job of the error-handler is to do something intelligent with the request. Possible use-cases are:

  • Use as the direct entry to the search-page like in
  • Use to do simple caching. If the requested file doesn’t exist, let the handler generate it. The next request will get the static version.

This makes it pretty flexible.

Please note that we won't accept comments for posts older than 3 months! Also please use our bug tracker to report bugs, and our irc channel #lighttpd@libera to chat.

« lighttpd unleashed - part two graceful restart »