On OpenBSD's httpd, there are only a select few MIME types that are
recognized by default. According to
httpd.conf(5), those types are:
application/octet-stream by default.
This is OK for most static hosting situations, but can be challenging
for some common attachment types. For example, I recently made a blog
post that had an attached PDF. Normally web browsers open PDF files in
the browser's PDF viewer, but since it was being returned with the
application/octet-stream, the browser decided to download
it instead of opening it directly. This isn't a tragedy, but it can
be annoying and interrupt the flow of the user's experience.
The solution to this is to include the
application/pdf MIME type in
TYPES block in your
httpd.conf. There are two ways to go about
this. Either by manually defining the type you require, or including
the system's built-in MIME type database.
Using the first method you would include a types block that defines all of the MIME types you require. This types block can go anywhere outside of a server declaration.
The types are defined in the format of
type/subtype name [name ...].
text/html html htm
image/jpeg jpeg jpg
The second method, including the system's built-in MIME types
database, is simpler if you need to support proper MIME types for a
larger number of files, and don't want to go through the process of
writing them all in by hand. This is done by defining a similar types
block, but instead of writing in type data, you use the
directive. OpenBSD's MIME type definitions are stored in
After editing the configuration file, all you have to do is reload
httpd, and it should begin recognizing file types properly.
doas rcctl reload httpd