Le Blog Utux

HTTP 200 GET /

OpenBSD: get rid of Comic sans ms in httpd error messages

Rédigé par uTux Aucun commentaire

I have been playing with OpenBSD and httpd lately. It's a really simple and fun webserver to use, despite suffering huge limitations, but I quickly stumble across this horror:

No joke. httpd will serve all errors messages with the infamous Comic sans ms font. It's probably a troll from the maintainers, at least I hope so. Comic sans ms sucks, I don't want that on my server. Fortunately, there is a simple way to disable it.

Add this line into your /etc/httpd.conf:

errdocs "/errdocs"

Then create the file /var/www/errdocs/err.html with the following content:

<!DOCTYPE html>
<meta charset="utf-8">
<style type="text/css"><!--
body { background-color: white; color: black; }
hr { border: 0; border-bottom: 1px dashed; }
@media (prefers-color-scheme: dark) {
body { background-color: #1E1F21; color: #EEEFF1; }
a { color: #BAD7FF; }

Then restart httpd:

rcctl restart httpd

Explanation: httpd manage says:

A custom error document may contain the following macros that will be expanded at runtime:

    The error message text.
    The 3-digit HTTP response code sent to the client.
    The server software name of httpd(8).

So I just took the source code of a 404 error page, removed the Comic sans ms part in the CSS and replaced the values (error code, message, server identity) by the proper variables. Now all errors messages should be generated with this new template, with a fallback font.

Écrire un commentaire

Quelle est le premier caractère du mot 826ni5qb ?